iPad:UIModalPresentationFormSheet 在横向模式下失败
我们的 iPad 版本遇到了下一个问题。
我在 UITabBar 中有一个 NavigationController。我想显示一个外观和感觉与电子邮件表单相似的表单。
我使用相同的代码来显示居中的模型:
// View to be displayed in the modal
AdhocViewController *controller = [[AdhocViewController alloc] initWithNibName:@"AdhocViewController" bundle:[NSBundle mainBundle]];
controller.caller = self;
// The form will need a navigation bar to cancel or save the form
UINavigationController *modalViewNavController = [[UINavigationController alloc]
initWithRootViewController:controller];
// Configurate the modal presentation and transition
modalViewNavController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
modalViewNavController.modalPresentationStyle = UIModalPresentationFormSheet;
// Show the new view
[self presentModalViewController:modalViewNavController animated:YES];
此代码在纵向模式下完美运行,但在横向模式下,视图部分出现在屏幕之外......而且我还没有找到解决它的方法。
我测试了我在这里找到的一些解决方案...
并尝试在预设模型视图后添加下一行以调整其大小,但没有解决
controller.view.superview.frame = CGRectMake(0, 0, 600, 700);
controller.view.superview.center = self.view.center;
有什么建议吗?
谢谢,
Ivan
参考文献StackOverflow:
- iPad modalPresentationStyle UIModalPresentationFormSheet方向问题
- UIModalPresentationFullScreen 在 iPad 横向模式下无法工作?
- <一href="https://stackoverflow.com/questions/3044262/uimodalpresentationformsheet-on-ipad-in-landscape-mode">iPad 上横向模式下的 UIModalPresentationFormSheet
- 如何调整UIModalPresentationFormSheet?
We've the next problem in our iPad version.
I've a NavigationController inside a UITabBar. I want to show a Form with a look&feel similar than the e-Mail form.
I use the same code to show a model centered:
// View to be displayed in the modal
AdhocViewController *controller = [[AdhocViewController alloc] initWithNibName:@"AdhocViewController" bundle:[NSBundle mainBundle]];
controller.caller = self;
// The form will need a navigation bar to cancel or save the form
UINavigationController *modalViewNavController = [[UINavigationController alloc]
initWithRootViewController:controller];
// Configurate the modal presentation and transition
modalViewNavController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
modalViewNavController.modalPresentationStyle = UIModalPresentationFormSheet;
// Show the new view
[self presentModalViewController:modalViewNavController animated:YES];
This code works perfectly on portrait mode, but on landscape the view appears partially out of the screen ... and I didn't found yet the way to solve it.
I test some of the solutions I found here ...
And try to add the next lines after preset the model view to resize it, but doesn't work it out
controller.view.superview.frame = CGRectMake(0, 0, 600, 700);
controller.view.superview.center = self.view.center;
Any suggestion?
Thanks,
Ivan
References in StackOverflow:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 iOS7,技巧是将 modalTransitionStyle 设置为 UIModalTransitionCrossDissolve。
https://coderwall.com/p/vebqaq
With iOS7 the trick is to set the modalTransitionStyle to UIModalTransitionCrossDissolve.
https://coderwall.com/p/vebqaq
最后是下一个代码:
+10 和 -10 是因为默认情况下模式的 NavigationController 位于顶部屏幕之外。
这是......一个蹩脚的解决方案:SS但有效......尽管如果有人有建议会很高兴知道。
如果我需要为两个方向包含相同的中心,那么超级视图的方向可能不是预期的方向。
在此解决方案中,当我关闭纵向模式视图时,至少在 iPad 模拟器上,它会自动旋转到纵向模式...
最终的解决方案是在主控制器 UITabBar 上执行presentModalViewController,并更新关闭方法也可以在其上执行。
最后!!!!
谢谢你,
伊万
Finally the code was the next:
The +10 and -10 is because by deafult the NavigationController of the modal was out of the screen on top.
It is ... a crappy solution :SS but works ... Although if anybody have suggestions would be nice to know.
Seams that if I need to include the same center for both orientation, maybe the orientation of the superview is not the expected one.
In this solution, when I dissmiss the modal view on Portrait orientation, at least on the iPad simulator, it rotate to portrait mode automatically ...
The final solution was to execute the presentModalViewController over the main controller, the UITabBar, and update the dismiss method to be executed also over it.
Finally!!!!
Thank you,
Iván
在 iOS 7 中,为了解决模式视图控制器在键盘出现后出现在左侧的问题(当我在 UIModalPresentationFormSheet 中呈现 EKEventEditViewController 时遇到的问题,我这样做:
In iOS 7, to solve the problem of the modal view controller to appear to the left after apparition of the keyboard (problem that I have when I present an EKEventEditViewController in UIModalPresentationFormSheet, I do :