How do I get the correct view size for a UIModalPresentationFormSheet in iOS 8?

I have a view that I am showing with the UIModalPresentationFormSheet presentation style on iPad for the welcome screen. Here is the code to represent the view. This is called in viewDidLoad for my main screen if the welcome screen has not been shown previously.

UIStoryboard *welcomeStoryboard = [UIStoryboard storyboardWithName:[NSString stringWithFormat:@"Welcome_%@", (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? @"iPad" : @"iPhone")] bundle:nil];
    self.welcomeViewController = [welcomeStoryboard instantiateViewControllerWithIdentifier:@"welcome"];

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
    self.welcomeViewController.modalPresentationStyle = UIModalPresentationFormSheet;

    if(IS_OS_8_OR_LATER){
        self.welcomeViewController.preferredContentSize = CGSizeMake(540.0f, 620.0f);
    }
}

[self presentViewController:self.welcomeViewController animated:NO completion:NULL];

      

In iOS 7, the view is configured correctly and the content flows as it should:

Form Sheet on iOS 7

In iOS 8, the modal size is correct, but the view still displays the full screen. When I write the size of the view to log it is 768 x 1024 after viewDidAppear (where 540 x 620 on iOS 7)

Form Sheet on iOS 8

How do I show a modal view the same size as in the form sheet?

+3


source to share





All Articles