Search code examples
iosipadmodal-dialogpresentviewcontroller

PresentViewController: animated not displaying on iPad


I am integrating SLService for Twitter into an application. It works great on iPhone but disappears on iPad.

I have integrated on the iPad:

  [actionSheet showFromRect:self.myRect inView:self.tableView animated:YES];

rather than:

 [actionSheet showInView:[UIApplication sharedApplication].keyWindow];

Is there a similar method for the iPad in lieu of presentViewContoller: Animated:?

    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
    {
        SLComposeViewController *tweetSheet = [SLComposeViewController
                                               composeViewControllerForServiceType:SLServiceTypeTwitter];
        [tweetSheet setInitialText:self.textForTweet];

        [self presentViewController:tweetSheet animated:YES completion:nil];
    } else [self displayAlertBoxWithTitle:@"Tweet Failed" message:@"Please try again later" cancelButton:@"Close"];
}

Should I be using a Modal dialog instead?


Solution

  • I missed this error message at first:

    Warning: Attempt to present <SLComposeViewController: 0x175d6560>  on <ScheduleTableViewController: 0x17538c20> which is already presenting (null)
    

    That lead me to discussion of same problem in a different context here.

    Resolved the issue by suggested work around:

    dispatch_async(dispatch_get_main_queue(), ^ {
                [self presentViewController:tweetSheet animated:YES completion:nil];
            });