- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最近想做一个自学的App,这个App是iOS的通讯录App。首先,我有两个 UITableViewControllers 连接到 UITabBarViewController。然后我想通过编码将 UINavigationController 与这两个 TableView 一起嵌入(在这种情况下,我不想通过设计将它嵌入 Storyboard 中)。但我坚持下去。这是我在 AppDelegate
中的代码func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let tabBar : UITabBarViewController = UITabBarViewController()
let tableView1 : UITableViewController = UITableViewController()
let nav = UINavigationController(rootViewController: tableView1)
let tableView2 : UITableViewController = UITableViewController()
let nav2 = UINavigationController(rootViewController: tableView2)
tabBar.viewControllers = [nav, nav2]
self.window?.rootViewController = tabBar
return true
}
并且结果总是显示第一个tableView1。我怎样才能在 UITabBarViewController 中显示两个选项卡选项(在 View 的底部)?如果我通过在 Storyboard 中进行设计来实现,我相信它会很好地工作。但是通过编码,我不知道如何修复它。请指导我。提前致谢!
最佳答案
UIKit 中没有UITabBarViewController
。它称为 UITabBarController
。您的 ViewControllers 需要有 NavigationItems。如果您像在代码中那样显示它们,您将在底部有一个 Tabbar,但上面没有任何可见内容。在您的情况下,NavigationControllers 是您需要定义 nav.navigationItem.title = ...
编辑:我意识到你没有初始化窗口。这与您的其他问题无关,但您的代码看不到任何内容。所以你必须把它改成:
self.window = UIWindow(frame: UIScreen.mainScreen().bounds);
self.window?.rootViewController = tabBar
self.window?.makeKeyAndVisible();
关于ios - 我想通过在 Swift 中以编程方式将 UINavigationController 与 UITableViewController 嵌入,这是 UITabBarViewController 的 subview ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26942245/
使用登录后,我想吐出用户名。 但是,当我尝试单击登录按钮时, 它给了我力量。 我看着logcat,但是什么也没显示。 这种编码是在说。 它将根据我在登录屏幕中输入的名称来烘烤用户名。 不会有任何密码。
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎是题外话,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或include a min
我是一名优秀的程序员,十分优秀!