tabBar 控制器中超过 5 个 tabBar 项目的问题
在将 tabBar 与导航控制器一起使用时,我遇到了一些问题。每个 tabBar 项目都与单独的导航控制器关联。问题列出如下:
1.我的 tabBar 中有超过五个 tabBar 项目,因此默认情况下会出现更多 tabBar 项目。现在,当我点击更多 tabBar 项目时,剩余的项目会出现在表视图中,这实际上是导航控制器的视图(默认情况下)。现在,当我选择任何行时,我的新视图控制器会被推入该导航控制器中。我希望我的视图控制器成为导航控制器。因此存在一种情况,例如将导航控制器推到另一个导航控制器的袋子上。编译器会感到困惑并且什么也不做。
2.虽然我已经设置了标签栏控制器的每个控制器的自动调整大小,但旋转设备时没有任何反应。但是,当我只保留五个或更少的选项卡栏项目时,自动调整大小效果很好。
3.我希望在整个应用程序的顶部有一个 ImagView,因此我在窗口本身上附加了一个 imageview,然后增加了 tabBar 控制器视图的 y 坐标,以便每个 tabBar 控制器视图的导航栏从 imageview 的正下方开始。纵向模式一切都很好,但是一旦我旋转设备,图像视图就会消失。当我再次进入纵向模式时,图像视图不会出现,并且 tabBar 控制器的视图从顶部开始。
我尝试了各种方法(例如 tabBar 而不是 tabBar 控制器等),但未能实现任何有用的效果。
I am facing few problems while using tabBar with navigation controllers.Each tabBar item is associated with a separate navigation controller.Problems are listed as follows:
1.There are more than five tabBar items in my tabBar so a more tabBar item comes by default.Now when i tap the more tabBar item the remaining items come in a tableview which is actually the view of a navigation controller(which comes by default).Now when i select any of the row, my new view controller gets pushed into that navigation controller.I want my view controller to be the navigation controller.So there is a situation like pushing a navigation controller onto the sack of another navigation controller.The compiler gets confused and it does nothing.
2.Although I have set autoresizing of each controller of tab bar controller nothing happens on rotating the device.However when I keep only five or less tabBar items,autoresizing works perfectly.
3.I want an ImagView at the top throughout the application, so I attached an imageview on the window itself and than increases the y-coordinate of the tabBar controller's view so that the navigation bar of each tabBar controller's view starts just below the imageview.Everything is fine for the portrait mode but as soon as i rotate the device the imageview dissappears.And when i again come to portrait mode the imageview does not appear and the tabBar controller's view starts from the top.
I tried it every ways(like tabBar instead of tabBar controller etc.) but fail to achieve anything helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前从未听说过这个问题。你能粘贴一些代码吗?另外,您确定“查看更多”页面上的选项卡正常工作吗?
为了使 TBC 旋转,每个选项卡的所有根视图控制器都必须支持旋转。在每个文件中,确保 shouldRotateToInterfaceOrientation: 对于所有方向都返回 YES(如果您使用默认的 iPhone VC 模板,请取出 if(interfaceOrientation == UIInterfaceOrientationPortrait) 语句和关联的括号)。
我以前确实这样做过,请相信我,当我说你正在打开一罐蠕虫时。要实现此目的,您需要将 TBC 添加为顶部有图像视图的视图的子视图。您必须手动设置 TBC.view 框架,以免覆盖顶部图像。执行此操作的最佳方法是:在容器文件的 .xib 中,在顶部添加一个图像视图,并在其下方添加另一个视图。通过 IBOutlet 将视图连接到代码,并将该框架设置为 TBC.view.frame。然后以编程方式将 TBC.view 添加为子视图。
然而,使用此解决方案,您必须添加一个 willRotateToInterfaceOrientation:duration: 方法,该方法在所有 TBC 的视图控制器中调用相同的函数,并且所有这些视图控制器都必须是手动调用 viewWillAppear: 和 viewDisappear: 的导航委托。当你这样做时,旋转也有点“粘”,所以要小心。
我的建议:不要将静态图像放在顶部。它会引起很多问题,并占用大量屏幕空间,尤其是在 iPhone 较小的屏幕上。如果您想看看天气频道应用程序看起来有多糟糕,请查看它。
如果您还有其他问题,请告诉我!
I've never heard of that problem before. Can you paste some code? Also, are you sure that the tabs on the view more page work correctly?
In order for a TBC to rotate, all of the root view controllers of each tab must support rotation. In each of those files make sure shouldRotateToInterfaceOrientation: returns YES for all orientations (if you're using the default iPhone VC template take out the if(interfaceOrientation == UIInterfaceOrientationPortrait) statement and associated brackets).
I've actually done this before, and trust me when I say you're opening up a can of worms. To achieve this you need to add the TBC as a subview of a view that has an imageview on top. You must manually set the TBC.view frame to not cover up the top image. The best way to do this is: in the .xib for the container file, add an image view up top, and under it another view. Connect the view to the code via an IBOutlet, and set that frame as the TBC.view.frame. Then add the TBC.view as a subview programmatically.
With this solution, however, you must add in a willRotateToInterfaceOrientation:duration: method that calls the same function in all the TBC's viewcontrollers, and all of those viewcontrollers must be navigation delegates that call viewWillAppear: and viewDisappear: manually. The rotation is also a bit "sticky" when you do this, so beware.
My suggestion: don't put a static image up top. It causes a lot of issues, and takes up a lot of screen real estate, especially on the iPhone's smaller screen. Look at The Weather Channel app if you want to see how bad it looks.
Let me know if you have any more questions!