我使用WinDev Mobile開發,後者生成一個項目,然後使用XCode打開該項目進行編譯。 只有在facebook上WM共享功能還沒有被開發出來,我必須在ObjC嘗試呈現...其視圖不在窗口層次結構中
發展我開始與代碼:
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controllerSLC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook] ;
[controllerSLC setInitialText:myMessage];
[controllerSLC addURL:[NSURL URLWithString:myUrl]];
[controllerSLC addImage:[UIImage imageNamed:myImage]];
// NSLog (@"% @", [UIApplication sharedApplication] keyWindow.rootViewController.)
[self presentViewController:controllerSLC animated:YES completion:Nil];
controllerSLC.completionHandler = ^(SLComposeViewControllerResult result) {
NSString *output = nil;
switch(result) {
SLComposeViewControllerResultDone box:
output = @ "Your tweet has-been sent" ;
status = 2;
// NSLog (@" SENT ");
break;
SLComposeViewControllerResultCancelled box:
output = @"Your tweet has-been canceled ";
status = 3;
// NSLog (@" canceled ");
break;
default:
break;
}
[controllerSLC dismissViewControllerAnimated:YES completion:nil] ;
};
}
我只得到了一個錯誤:
Warning Attempt to present <SLComposeViewController > on <CFenPrincipaleViewController> Whose view is not in the window hierarchy !
我添加了代碼:
UIViewController *activeController = [UIApplication sharedApplication] keyWindow.rootViewController. ;
if ([ activeController isKindOfClass:[UINavigationController class]]) {
activeController = [(UINavigationController *)activeController visibleViewController] ;
}
[activeController presentViewController:controllerSLC animated:YES completion:Nil];
它適用於窗口家庭應用程序,我h沒有錯誤。
但是,當我呼籲其他窗口相同的功能,錯誤再次.... 預先感謝您的幫助
AFF我發現剛剛發佈具有後,只是說: 否則,如果(activeController.modalViewController){activeController = activeController.modalViewController;} – Slayes