“默认"在 UITabBarController 中查看 [英] "Default" view in UITabBarController

查看:20
本文介绍了“默认"在 UITabBarController 中查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 5 个导航控制器的 UITabBarController,作为选项卡嵌入其中(类似于下面的图片 1).所以,问题是:当显示 TabBarController 时,我想将表视图(或任何其他视图)显示为默认"视图.即,显示未嵌入 TabBarController 的视图(视图控制器)并选择任何选项卡.我为这样的解释道歉,最好看下面的图片#2.我在我的项目中使用最新版本的 XCode 和 Swift.对于界面,我使用的是故事板

I have a UITabBarController with 5 NavigationControllers, embedded in it as tabs (similar to picture 1 below). So, the question is: I want to show the table view (or any another view) as a "default" view, when the TabBarController is shown. I.e., show the view (view controller), which is not embedded in TabBarController and make any tab selected. I apologize for such explanation, better watch on picture #2 below. I'm using latest version of XCode and Swift in my project. And for interface I'm using storyboard

推荐答案

您可以决定在第一个(初始)viewController 中选择哪个选项卡.

You can determine which tab to select in the first (initial) viewController.

注意:Swift 3

override func viewDidLoad() {
    super.viewDidLoad()

    self.tabBarController?.selectedIndex = 1
  }

请注意,默认情况下,第一个选定的 viewController 位于 0 索引处 (self.tabBarController?.selectedIndex = 0)

Note that by default the first selected viewController is at 0 index (self.tabBarController?.selectedIndex = 0)

这篇关于“默认"在 UITabBarController 中查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆