UITabBarViewController - 保持故事板连接?
UITabBarViewController - Keep Storyboard Connections?
如果我以编程方式创建 UITabBarItem,是否可以保留情节提要@IBOutlets?
例如:
let vc2 = BellTabVC()
let icon2 = UITabBarItem(title: "Home", image: nil, selectedImage: nil)
vc2.tabBarItem = icon2
self.viewControllers = [vc2]
然而,这在线崩溃了,
tableView.delegate = self
当 tableView 是 @IBOutlet 时。
谢谢!
发生崩溃,因为以编程方式创建的 class 不再连接到故事板。
你可以做的是在代码中加载情节提要控制器 包括 实现的 class 和插座,像这样:
let controller = storyboard?.instantiateViewControllerWithIdentifier("YourProfileViewController") as! YourProfileViewController
然后你可以用你的控制器做你想做的事(将它加载到另一个控制器,改变它......)。
如果我以编程方式创建 UITabBarItem,是否可以保留情节提要@IBOutlets?
例如:
let vc2 = BellTabVC()
let icon2 = UITabBarItem(title: "Home", image: nil, selectedImage: nil)
vc2.tabBarItem = icon2
self.viewControllers = [vc2]
然而,这在线崩溃了,
tableView.delegate = self
当 tableView 是 @IBOutlet 时。
谢谢!
发生崩溃,因为以编程方式创建的 class 不再连接到故事板。
你可以做的是在代码中加载情节提要控制器 包括 实现的 class 和插座,像这样:
let controller = storyboard?.instantiateViewControllerWithIdentifier("YourProfileViewController") as! YourProfileViewController
然后你可以用你的控制器做你想做的事(将它加载到另一个控制器,改变它......)。