我使用动态UITableView控件显示菜单。菜单可以根据特定条件进行更改。现在,我希望当我点击菜单项时,它会带我到另一个控制器。
我如何才能做到这一点,而不必创建多个在故事板?我有9-10选项显示在UITableView中,我真的不想在故事板中创建9-10个不同的图标。
发布于 2015-09-23 18:30:32
您可以始终以编程方式加载控制器。设置控制器的Storyboard ID,如图所示:

然后,如果您只有一个故事板,就可以像这样加载加载控制器:
if let controller = self.storyboard?.instantiateViewControllerWithIdentifier("SettingsViewController") {
self.navigationController?.pushViewController(controller, animated: true)
}如果您有多个故事板,则应该使用:
let controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("SettingsViewController")
self.navigationController?.pushViewController(controller, animated: true)https://stackoverflow.com/questions/32746717
复制相似问题