Ios – Modal UIViewController always coming out full screen on iPad. WHY

iosiphoneuiviewcontroller

I am trying to create a simple modal dialog on the iPad, in either the small (UIModalPresentationFormSheet) or the larger (UIModalPresentationPageSheet) settings, but they come out full screen (with a title bar) no matter what I do.

The modal UIViewController was created in interface builder where I can't seem to specify a size for it. Specifying a smaller size for the UIView contained within the UIViewController has no effect.

What am I doing wrong? What would possibly affect this issue? Could it be the timing in which I am setting modalPresentationStyle? I have tried both using a UINavigationController and without, but am getting the same result.

Best Answer

You must set modalPresentationStyle in the parent ViewController before calling presentModalViewController:animated.

myViewController = // create your new controller if needed 
myViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
myViewController.modalPresentationStyle = UIModalPresentationFormSheet;
// "self" is the parent ViewController
[self presentModalViewController:myViewController animated:YES]