使用 UIModalPresentationFormSheet 的模态视图出现在屏幕外
我有一个 UIViewController 实现
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
然后,我尝试在该视图顶部弹出一个模式:
ModalViewController *modalViewController = [[ModalViewController alloc] init];
modalViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
modalViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[mainViewController presentModalViewController:modalViewController animated:YES];
如果我在 ipad 处于纵向时启动模式,它工作正常。但是,当我横向握住它并尝试启动模式时,模式会出现一半在屏幕外,位于 iPad 的右上角。有什么想法吗?
I have a UIViewController that implements
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Then, I try to popup a modal on top of that view:
ModalViewController *modalViewController = [[ModalViewController alloc] init];
modalViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
modalViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[mainViewController presentModalViewController:modalViewController animated:YES];
If I launch the modal while the ipad is in portrait, it works fine. But when I'm holding it in landscape and try to launch the modal, the modal appears half offscreen to the upper right of the ipad. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 ModalViewController 中,以与 mainViewController 中相同的方式实现shouldAutorotateToInterfaceOrientation(两者都需要就它们支持的方向达成一致)。
In ModalViewController, implement
shouldAutorotateToInterfaceOrientation
the same way that it is in mainViewController (both need to agree on the orientations they support).