سؤال

I'm trying to integrate Facebook on iOS6 for an iPad app and run into a problem:

When the following code executes, the screen fades to dark (like when a modal controller appears) but then nothing happens. No Facebook sheet, nothing - Cannot even tap on the current view as if the facebook sheet is hidden or something.

Any idea as to why this may be happening? I tried to use the root view controller and the visible/top controllers of the UINavigationController to present the sheet but all do the same.

Btw, the code below is in the AppDelegate. Also the method is called in response to a button click.

thanks, Nikos.

-(BOOL)socialPost:(UIImage*)image initialText:(NSString*)initialText url:(NSURL*)url
{
    if (![self canSocialPost])
        return NO;

    SLComposeViewController* SLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    if (SLComposerSheet == nil)
        return NO;

    [SLComposerSheet setInitialText:initialText];
    [SLComposerSheet addImage:image];
    [SLComposerSheet addURL:url];
    [SLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {

        switch (result) {
            case SLComposeViewControllerResultCancelled:
                DLog(@"Social post Canceled");
                break;
            case SLComposeViewControllerResultDone:
                DLog(@"Social post Sucessful");
                break;

            default:
                break;
        }
    }];

    [[self window].rootViewController presentViewController:SLComposerSheet animated:YES completion:nil];
    return YES;
}
هل كانت مفيدة؟

المحلول

0x7fffffff is right - the problem was actually somewhere else:

I was adding nested views to the 'root view' but did not add their view controllers as a child too, i.e.

I was doing:

[_ContainerView addSubview:_ViewControllers[tabId].view];

without

[self addChildViewController:_ViewControllers[tabId]];

It's now fixed - thank you for testing this 0x7fffffff.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top