使用设备方向来实现模态视图控制器
请原谅我的菜鸟问题,这是我的第一个问题,老实说,我花了相当大的努力来寻找自己的解决方案。
我有一个带有两个视图控制器的项目。主要的仅是纵向视图,第二个(子)模式视图控制器仅以横向模式呈现。我的目标是让设备的方向单独切换控制器(并向模态视图控制器提供函数调用,同时从主视图控制器传递某些 ivars),类似地,我希望将其重新定向为纵向关闭模态视图并恢复到起点。
我想这有点像苹果自己的计算器应用程序的工作原理?有人可以告诉我最符合 API 的方法吗? 非常感谢您抽出时间。
我非常希望避免模式视图上的“后退”或“完成”按钮,并且仅在可能的情况下才随设备方向来回更改
Please forgive me a noob question, its my first and i honestly expended a considerable effort searching for my own solution.
I have a project with two view controllers. the main on is a portrait view only and the second (sub) modal view controller is to present in landscape mode only. My goal is to have the orientation of the device alone switch the controllers (and to provide a function call to the modal view controller, passing on certain ivars from the main view controller at the same time) similarly I would like a reorienting to portrait to dismiss the modal view and revert to the starting point.
I imagine this is somewhat how apples own calculator app works? Can anybody give me a clue about the most API compliant way to go about this?
Thank you so much for your time.
I would very much like to avoid a 'back' or 'done' button on the modal view, and change back and forth with the device orientation only if this is at all possible
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Apple 为您想要做的事情提供了很好的解释和示例代码。请参阅 视图控制器编程指南中的创建备用景观界面。
Apple has a good explanation and sample code for exactly the thing you want to do. See Creating an Alternate Landscape Interface in the View Controller Programming Guide.
如果您为视图启用了旋转,那么在
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientationuration:(NSTimeInterval)duration
中,您可以检查方向和相应的操作,如下所示:If you have rotation enabled for your views then in
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
You can check the orientation and the act accordingly like this: