I'm trying to present a view controller with its presentation style set to form sheet. However, when the view controller appears, it is positioned to the right of the screen, not in the center. I am not sure why this is happening, or what I should do. All of these coordinates are correct!
CGSize size = CGSizeMake(650, 550);
//custom init for ViewController so I can position stuff correctly
ViewController *vc = [[ViewController alloc] initWithSize:size];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
nav.modalPresentationStyle = UIModalPresentationFormSheet;
nav.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:nav animated:YES];
nav.view.superview.frame = CGRectMake(0, 0, size.width, size.height);
nav.view.superview.center = self.view.center;
It seems that whenever I remove the last two lines, I get what I assume to be the behavior that you are looking for.
CGSize size = CGSizeMake(650, 550);
//custom init for ViewController so I can position stuff correctly
ViewController *vc = [[ViewController alloc] initWithSize:size];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
nav.modalPresentationStyle = UIModalPresentationFormSheet;
nav.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:nav animated:YES];
I'm not sure exactly what you were trying to do with those two lines, but without them the view is centered.
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