我想打开“选择城市”控制器,当selectedCityId为0(未定义)时 – 选择一个城市.在viewDidLoad()中的根视图控制器(MainVC)中: let selectedCityId = NSUserDefaults.standardUserDefaults().integerForKey("selectedCity
let selectedCityId = NSUserDefaults.standardUserDefaults().integerForKey("selectedCityId") if(selectedCityId == 0){ self.performSegueWithIdentifier("startupSegue", sender: self) } else { .... }
所以startupSegue以模态方式打开settingsViewController(SettingsVC)!两者 – MainVC和SettingsVC都嵌入了导航视图控制器.
有2个警告:
Presenting view controllers on detached view controllers is
discouraged “myapp.MainVC: 0x7fee8871e670”.Unbalanced calls to begin/end appearance transitions for
“UINavigationController: 0x7fee8872c950”.
谢谢你的回答.
我有同样的警告并通过将代码移动到-viewDidAppear来修复它.您应该注意的一件事是-viewDidLoad只被调用一次,而如果页面变得可见,则可以多次调用-viewDidAppear,因此您需要添加其他机制以再次跳过执行segue.