I have a problem with iOS 7 that seems to be a bug or I just don't do something right. I have modalViewController that appears as a popover on iPad with ModalPresentationStyle. And it is not standard size, custom sized. Here is the code:
myViewController *myVC = [[myViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:myVC];
[nav setModalPresentationStyle:UIModalPresentationFormSheet];
[nav setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal];
[self presentViewController:nav animated:YES completion:nil];
nav.view.superview.bounds = CGRectMake(0, 0, 320, 465);
It's all working fine in iOS 6, but in iOS 7 it's not centered. But if I set ModalTransitionStyle to UIModalTransitionStyleCrossDissolve it works fine. But only in this mode. Maybe someone stumbled on this one too and know how to fix it? I'm not a big fan of dissolve effect. Thank you.
It's the same for me... I don't know yet how to solve it. I'm currently working in that issue so anything I get I'll share it!
This is my code.
}
I went about this slightly differently using a subclassed navigation controller and AutoLayout in Swift, to center the view in the superview at a set width and height. My particular case needed iPad and iOS7-8 support (there's some constants specific to my project in this code, but you get the idea) ...
...
The solution above did not work for me. I used the following:
I had the same problem. I have solved this by using another approach, found here.
What this solution proposes is to use the method
(void)viewWillLayoutSubviews
So in case of @Manuel M. inside the
GeneralSettingsViewController
add the code below:And you won't need this code anymore:
For @titicaca, you are using a
UINavigationController
I haven't test it with this Controller but you could try the same solution I mentioned, extending theUINavigationController
and overwrite theviewWillLayoutSubviews
method.[EDIT]
For @titicaca I tried it in a new project and for me it worked. What I did was having a custom navigation view controller
CustomNavigationController
overriding theviewWillLayoutSubviews
like this:Then, the view controller that presents the
CustomNavigationController
should execute a code similar to this:You need to make sure though, that the dimensions of the
self.view.superview.bounds = CGRectMake(0, 0, 330, 284);
are even numbers otherwise the text inside gets fuzzy, if there is anyFor me the issue was calling
becomeFirstResponder
on a text field in theviewDidAppear
of the presented view controller. Appears to be a bug with that now. The solution was wrapping it in a simpledispatch_async
:I have a method where the old custom modal presentation style
fromsheet
works withiOS <=7
although you might setcustom height and width
.Keep in mind that this method might not work in any newer version in the future