xcode 两个 uitabbarcontrollers 一页。自动旋转问题
Summery:
- 我有一个自定义的 UITabBarAutoRotateController,它从 shouldAutorotateToInterfaceOrientation 返回 YES。这没有效果。
- 如果我最小化并再次显示应用程序,旋转问题就会消失。
- 如何刷新屏幕以便用户不必执行此操作(以便旋转再次起作用)?
详细信息(以图形方式设置,因此无需代码):
我在 MainWindow.xib 中有两个 UITabBarController。我一次只想显示一个。所以我以图形方式链接 rootViewController = tabBarController_name1。还有 tabBarController_name2。
我还将有一个警报消息框,供用户选择他们需要的应用程序类型,并且它将根据他们的请求(根据客户定义)选择选项卡栏控制器。目前已将其注释掉。
当同一个 xib 上存在两个 UITabBarController 时,旋转会出现错误。当我尝试旋转屏幕时,它与主屏幕按钮(电源按钮外观按钮)所面向的任何位置保持向上。 HandleOrientationChange 不会在显示的活动自定义 ViewController 上调用。
我认为这是一个错误的原因是,如果我点击主屏幕按钮(最小化应用程序),然后单击返回应用程序(将其带回前台),旋转效果会完美!
很抱歉让您阅读了所有这些废话:)。我真正的问题是,“我是否可以刷新主窗口或类似的 UITabBarController 来让旋转工作(不需要最小化和显示程序)”?一个解决方法,如果你愿意的话?
ps 出于向后兼容性的原因,我无法使用 Storyboard。客户将收到此代码/项目。所以我想将其保留在一个图形页面中,而不是隐藏/显示 UITabBarItem。
编辑: 两个-uitabbarcontrollers-and-autorotation 和 uitabbarcontrollers-and-uinavigationcontrollers 都有帮助,但没有解决“为什么”会出现此问题。当谈到 xcode 时,这里是“noob”:)
Summery:
- I have a custom UITabBarAutoRotateController which returns YES from shouldAutorotateToInterfaceOrientation. This has no effect.
- If I minimize and show the app again, the rotation issue goes away.
- How do I refresh the screen so the user does not have to do this (so rotation works again)?
Details (setup graphically, so no code):
I have two UITabBarController in MainWindow.xib. I only want one to show at a time. So I am linking graphically rootViewController = tabBarController_name1. There is also tabBarController_name2.
I will also have an alert MessageBox for a user to choose what type of application they need, and it will choose a tab bar controller based on their request (per customer definition). This is commented out for now.
There is a bug with Rotation when two UITabBarControllers exist on the same xib. When I try to rotate the screen, it stays upward with wherever the main screen button (power button looking button) faces. HandleOrientationChange does not get called on the active custom ViewController being shown.
The reason I believe it's a bug is because if I hit the main screen button (minimizing the application), and click back on the application (brings it back to the foreground), rotation works perfectly!
Sorry for making you read all that mumbo :). My true question is, "Is there anyway I could refresh the main window or likewise UITabBarController's to get rotation working (without requiring the program be minimized and shown)"? A work-around, if you will?
p.s. I cannot use Storyboard for backwards compatibility reasons. The customer will be receiving this code/project. So I would like to keep this in one graphical page, rather than hiding/showing UITabBarItem's.
EDIT: two-uitabbarcontrollers-and-autorotation and uitabbarcontrollers-and-uinavigationcontrollers were both helpful, but did not address "why" this issue happens. "noob" here when it comes to xcode :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
导航控制器内的标签栏控制器,或者共享导航根视图就是答案。不要使用 TabBarViewController。作为一个菜鸟,我不太确定为什么 TabBarViewController 存在(或者至少没有贬值)。
将两个 TabBarViewController 拖到同一页面中应该会产生一条警告,指出您可能希望通过创建自定义 UIViewController 并向其附加普通 UITabBar 来实现 TabBarViewController。
令人沮丧...但终于取得了进展:)
Tab bar controller inside a navigation controller, or sharing a navigation root view is the answer. Do not use a TabBarViewController. Which, as a noob, I'm not quite sure why TabBarViewController exists (or at least isn't depreciated).
Dragging two TabBarViewControllers into the same page should result in a warning saying that you probably want to implement TabBarViewController by making a custom UIViewController and attaching a plain UITabBar to it.
Frustrating...but finally making progress :)