I developed using WinDev Mobile, which generates a project that I opened with Xcode for compilation. Only the WM sharing features on Facebook are not yet developed, I have to develop in ObjC
I started with the code:
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controllerSLC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook] ;
[controllerSLC setInitialText:myMessage];
[controllerSLC addURL:[NSURL URLWithString:myUrl]];
[controllerSLC addImage:[UIImage imageNamed:myImage]];
[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;
break;
SLComposeViewControllerResultCancelled box:
output = @"Your tweet has-been canceled ";
status = 3;
break;
default:
break;
}
[controllerSLC dismissViewControllerAnimated:YES completion:nil] ;
};
}
I got an error:
Warning Attempt to present <SLComposeViewController > on <CFenPrincipaleViewController> Whose view is not in the window hierarchy !
I added the code:
UIViewController *activeController = [UIApplication sharedApplication] keyWindow.rootViewController. ;
if ([ activeController isKindOfClass:[UINavigationController class]]) {
activeController = [(UINavigationController *)activeController visibleViewController] ;
}
[activeController presentViewController:controllerSLC animated:YES completion:Nil];
It works on the home window application, I have no error.
But when I call the same function in another window, the error returns .... Thank you in advance for your help.
source
share