Joq*_*qus 2 uitabbarcontroller uikit swift
我有一个故事野猪,视图上有一个按钮。当我单击该按钮时,我应该转到自定义的UITabBarController,但显示的只是一个空的选项卡栏。
let tabBar = TabViewController()
self.presentViewController(tabBar, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
在故事板上,我将TabBarController的类设置为TabViewController。我想念什么?
您需要在Interface Builder中为TabViewController提供一个故事板ID,并通过以下方式对其进行访问:
if let tabViewController = storyboard.instantiateViewControllerWithIdentifier("TheAssignedID") as? TabViewController {
presentViewController(tabViewController, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
您使用的代码只是创建TabViewController类的新实例。不访问您在Interface Builder中定义的原型。
| 归档时间: |
|
| 查看次数: |
4118 次 |
| 最近记录: |