iPhone:TabBarController 作为第二级导航控制器
我是 iPhone 开发新手。
我读过有关在窗口上实现选项卡栏控制器的教程(例如作为应用程序的主控制器)。但是如何创建一个选项卡栏控制器作为可以由导航栏控制器调用的“独立”UIViewController?
基本上,我的导航栏控制器有一个 UIViewController 数组,它显示在表中,然后在用户选择某个项目时加载适当的视图/控制器。
现在我希望这些加载的视图/控制器之一成为选项卡栏控制器。我该怎么做?
我不确定如何在应用程序委托中没有插座/实例的情况下自行创建选项卡栏控制器。
希望这是有道理的。谢谢。
I'm new to iphone development.
I've read tutorials about implementing a tab bar controller on the window (eg as the main controller for the app). But how can I create a tab bar controller as a 'standalone' UIViewController that can be called by a navigation bar controller?
Basically my navigation bar controller has an array of UIViewControllers that it displays in the table and then loads the appropriate view/controller when a user selects an item.
Now I want one of these loaded views/controllers to be a tab bar controller. How can I do this?
I'm not sure how to create a tab bar controller on its own without having an outlet/instance in the application delegate.
Hope that made sense. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然之前的答案是正确的,但我想指出苹果不会对此感到满意:
引用自: Apple View Controller 编程指南
阅读人机界面指南,您的应用可能会因“违反界面规则”而被拒绝。此外,您还必须手动处理所有 vieWillAppear/Disappear 等。我很确定还有另一种设计界面的方法。
问候,
保罗
Although previous answer was is correct, I'd just like to point out that Apple won't be happy with this:
Quotation from: Apple View Controller Programming Guide
Read Human Interface Guidelines, your app might be rejected for "breaking the interface rules". What's more, you'll also have to handle all the vieWillAppear/Disappear etc manually. I'm pretty sure there's another way of designing the interface.
Regards,
Paul
你有两个选择。
第一的。创建 UITabBarController(一般 alloc-init 的东西)并将其推送到 UINavigationController。
第二。您可以创建自定义 UIViewController 并将 UITabBar 放置在那里。之后,您可以对其进行自定义并将该自定义 UIViewController 推送到导航控制器。代码如下所示:
例如,您可以在 UIViewController 的 viewDidLoad 方法中使用类似的代码。
要处理选项卡更改事件,您必须实现 UITabBarDelegate 协议并将其分配给它(例如 UIViewController 本身):
之后,您必须实现
帮助您捕获事件的方法。
You have two options.
First. Create UITabBarController (general alloc-init stuff) and push it to UINavigationController.
Second. You can create custom UIViewController and place UITabBar there. After that you can customize it and push that custom UIViewController to navigation controller. Code will look like this:
You can use similar code in viewDidLoad method of UIViewController, for example.
To process tab change event, you'll have to implement UITabBarDelegate protocol and assign it (for example to UIViewController itself):
After that you'll have to implement
method that'll help you to catch events.