gpt4 book ai didi

iphone - 有好的 UITabBarController 示例吗?

转载 作者:太空狗 更新时间:2023-10-30 03:51:37 27 4
gpt4 key购买 nike

是否有一个很好的 UITabBarController 示例,它不是是在 appDelegate 中创建的?

我想在 UIViewController 中使用 UITabBarController,但是不知道如何设置 View 导出。

最佳答案

这就是全部 very well documented here . UITabBarController 实例的创建位置无关紧要,无论是否有 UIApplicationDelegate。简而言之,创建您各自的所有 UIViewController 并将它们添加到数组中。然后将该数组分配给您的 UITabBarController 的 viewControllers 属性。然后你可以简单地做一些像[window addSubview:myTabBarController.view]这样的事情。

我只是从此处的文档中复制/粘贴:

You should never access the tab bar view of a tab bar controller directly. To configure the tabs of a tab bar controller, you assign the view controllers that provide the root view for each tab to the viewControllers property. The order in which you specify the view controllers determines the order in which they appear in the tab bar. When setting this property, you should also assign a value to the selectedViewController property to indicate which view controller is selected initially. (You can also select view controllers by array index using the selectedIndex property.) When you embed the tab bar controller’s view (obtained using the inherited view property) in your application window, the tab bar controller automatically selects that view controller and displays its contents, resizing them as needed to fit the tab bar interface.

关于iphone - 有好的 UITabBarController 示例吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3011262/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com