In iOS 5 it runs correctly:
PinRequiredViewController *pinView = [[PinRequiredViewController alloc]initWithNibName:@"PinRequiredView" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:pinView];
// show the navigation controller modally
navController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalInPopover = NO;
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:navController animated:YES completion:nil];
navController.view.superview.frame = CGRectMake(0, 0, 250, 250);
navController.view.superview.center = self.view.window.center;
But not working fine in iOS6, the view does not stay centered in the screen, both portrait and landscape. Any solutions?
Thanks!! :)
I think it'll work if you remove the UIModalTransitionStyleFlipHorizontal
transition style and use one of the other transition styles instead.
Seems like it's a bug with UIModalTransitionStyleFlipHorizontal
.
Use the completion: in your presentViewController:
[self presentViewController:navController animated:YES completion:^{
navController.view.superview.bounds = CGRectMake(0, 0, 250, 250);}];
This will make it work with UIModalTransitionStyleFlipHorizontal
.
The problem is that you can set the frame of the superview to whatever you want but the origin will not be changed. That's the reason why it doesn't stay centered.
It looks like Apple restricted this on purpose in iOS6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With