iPad presentViewController is always Fullscreen (need formSheet) iOS6

jhilgert00 picture jhilgert00 · Dec 14, 2012 · Viewed 7.9k times · Source

I need to present a viewController as a formSheet when the user taps a 'settings' button in the navigation bar in the iPad side of my universal app. The view is called "SettingsViewController," and it's a View Controller in my iPad Storyboard with an ID of "settings".

I'm not using segues because in my iPad version of the app, I have more than one button in the navigation bar on the left side, so I have to add the buttons progammatically. (can't connect a segue to a nonexistent UIBarButtonItem in the storyboard.)

The functionality I want is there, the presentation is not. When I present my SettingsViewController, on the iPad, it's presenting as a full screen view. I need it to be a form sheet.

I'm wrapping it in a NavigationController, which I need and works fine, just need it to present itself in the correct manner.

Here's the code that presents the view:

-(void)showSettings:(id)sender {

    SettingsViewController *svc = [self.storyboard instantiateViewControllerWithIdentifier:@"settings"];
    svc.delegate = self;
    svc.modalPresentationStyle = UIModalPresentationFormSheet;
    UINavigationController *navcont = [[UINavigationController alloc] initWithRootViewController:svc];
    [self presentViewController:navcont animated:YES completion:NULL];

}

I've tried everything I can think of. Any help is deeply appreciated.

Answer

geraldWilliam picture geraldWilliam · Dec 14, 2012

Looks like you set the modal presentation style on SettingsViewController but you should have set it on your UINavigationController.