iOS 5 跨多个场景保持一致的标签栏
我正在 iOS 5 上开发我的第一个 Apple 产品。当我不使用 UITabBarController 时,在多个场景中保持一致的 UITabBar 对象的最佳方法是什么?它只是一个标准的 UIViewController。我让标签栏在一个场景中按照我想要的方式工作,并且我希望能够将其复制到其他 4 个左右的场景中。
I am developing my first Apple product on iOS 5. What is the best way to maintain a consistent UITabBar object across multiple scenes when I'm not using the UITabBarController? It's just a standard UIViewController. I have the tab bar working just as I want it on one scene and I want to be able to duplicate it to my other 4-ish scenes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
使用
UIAppearance
API 用于在所有UITabBar
实例上设置视觉属性。这里是可以在
UITabBar
的UIAppearance
上设置的属性列表 代理人:Use the
UIAppearance
API to set your visual properties on allUITabBar
instances.Here's a list of the properties that can be set on
UITabBar
'sUIAppearance
proxy:我认为这个创新的答案会对您有用
物理按钮
I think this innovative Answer will use for you
Physical Button
假设您确实不想使用
UITabViewController
,那么让您的应用程序委托维护对全局UITabBar
对象的引用,并且当您从一个视图切换到另一个视图时,您可以只需请求该实例并将其添加到视图层次结构中即可。Assuming you really don't want to use a
UITabViewController
, then have your application delegate maintain a reference to your globalUITabBar
object and as you switch from view to view, you can just request that instance and add it the view hierarchy.这非常简单且容易做到(我已经在多个应用程序中完成了)。
显示(包括初始/第一个视图)。我们称它们为 MyViewController1 &我的视图控制器2。
MyViewController2,添加 CABasicAnimation/CATransition 到
CALayers 到 MyViewController1 & MyViewController2(而不是
主视图控制器)。然后你的顶栏(画在
MainViewController)将保持坚如磐石的稳定,并且
MyViewController1 & 2 将在其下切换/动画。
如有任何问题,请随时提出。
It's very simple and easy to do (I've done it in multiple apps).
to show (including the initial/first view). Let's call them MyViewController1 & MyViewController2.
MyViewController2, add the CABasicAnimation/CATransition to
CALayers to MyViewController1 & MyViewController2 (and not the
MainViewController). Then your top-bar (drawn on
MainViewController) will remain rock-solid stable and the
MyViewController1 & 2 will switch/animate under it.
Feel free to ask any questions.
您可以做的是使用视图来包装您想要动态的内容。然后您可以将第一个可见视图添加为该视图的子视图。接下来,您需要为视图(当前视图和要更改为的视图)之间的过渡设置动画,以模拟更改视图控制器。这是我使用的代码,它在两个视图之间执行此操作。我的“包装”视图称为内容视图。您需要将其与您设置的选项卡栏集成...
尝试一下!
What you could do is use a view to wrap the content you want to be dynamic. Then you could add the first visible view as a subview of this view. Next you would need to animate a transition between the views ( the current view, and the one you want to change to ) to simulate changing a view controller. Here is code that I have used that does this between two views. My "wrapper" view is called content view. You would need to integrate this with what tab bar you have setup...
Try it out!
这不是标准方法,但如果您确实想在应用程序中提供 tabBar 功能而不使用 tabBar。
在每个视图的底部创建 4-5 个自定义按钮(带图像)(大小 199 X 49 ),以便它完全占用视图的底部(如 tabBar)。在一个视图休息中仅给出一个按钮操作全部都被禁用了。此外,您提供的按钮功能应该更改图像以显示当前选项卡被单击。
This is not the Standard way but if you really want to give tabBar functionality in your application without using the tabBar.
Create a 4-5 custom buttons(with images) at the bottom of every view (size 199 X 49 ) so that it entirely consume the bottom of the view (like tabBar).Give only one of the buttons action in a one view rest all are disabled. Also the button function you give should change the image to show that the current tab is clicked.