iPhone 横向导航返回动作显示垂直视图转换?
我有一个常规的 UINavigationController 并将一系列 UIViewController 推入堆栈。推送控制器的视图过渡是水平动画过渡: [self.navigationController PushViewController:控制器动画:是];
但是,当我按导航栏上的“后退”按钮时,视图过渡动画是垂直的(垂直下拉前一个控制器/视图)。
我似乎没有找到任何方法使其水平。这种情况仅发生在横向模式下。纵向模式下的过渡全部发生为水平翻转过渡。
任何人都可以阐明这一点吗?
谢谢
I have a regular UINavigationController and I push a series of UIViewController into the stack. The view transition for push controller is horizontal animation transition:
[self.navigationController pushViewController:controller animated:YES];
However, when I press the Back button on the navigation bar, the view transition animation is vertical (vertically dropping down the previous controller/view).
I don't seem to find any way to make this horizontal. This happens only in Landscape mode. Portrait mode the transition all happens as horizontal flip transition.
Can anyone shed any light on this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也有同样的问题。当我按回键进入第一个视图时,我看到了垂直动画而不是正常的水平动画。
我根据Apple的NavBar示例代码找到了答案。我编辑了示例代码,将“shouldAutorotateToInterfaceOrientation”添加到所有视图控制器,并使其返回 YES。
当我运行它时,我注意到按“后退”时使用了正确的动画。
修复:
似乎您需要在导航控制器中使用自己的子类 UIViewController,并添加 shouldAutorotateToInterfaceOrientation。据推测,默认的 UIViewController 没有返回正确的方向,因此使用了错误的动画。
背景:
我检查了我的代码和苹果代码之间的所有差异,我发现我的导航控制器是 UINavigationController 的子类,我在其中执行所有工作。默认情况下,IB 在其中添加了一个 UIViewController,但我保留了它。我注意到 NavBar 示例代码有自己的类集(MainViewController)。所以我让 Xcode 创建一个没有 xib 的新 UIViewController 子类,然后在 IB 的 Identity 面板的 Class 选项中设置它。
我希望这是有道理的并且有帮助!
I had the same problem. When I pressed back to get to the first view I saw a vertical animation instead of the normal horizontal one.
I found an answer based on Apple's NavBar sample code. I edited the sample code to add "shouldAutorotateToInterfaceOrientation" to all the view controllers, and made it return YES.
When I ran it I noticed the correct animation was used when pressing "Back".
FIX:
It seems like you need to use your own subclassed UIViewController within the navigation controller, and add shouldAutorotateToInterfaceOrientation. Presumably the default UIViewController isn't returning the correct orientation so the wrong animation is used.
BACKGROUND:
I checked all the differences between my code and Apple's, and I found out that my navigation controller was a subclass of UINavigationController, where I perform all the work. By default IB had added a UIViewController inside this, and I left it alone. I noticed that the NavBar sample code had its own class set (MainViewController). So I made Xcode create a new UIViewController subclass with no xib, then set it up in the Class option in the Identity panel in IB.
I hope this makes sense and helps!