我使用故事板并拥有以下风险投资:
UISplitViewController (Master) > UITabbarController > UINavigationController > UITableViewController
UISplitViewController (Detail) > UINavigationController > UIViewController
我想在启动时显示登录屏幕。
我添加了以下内容:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window?.rootViewController = self.window!.rootViewController as! UISplitViewController
window?.makeKeyAndVisible()
if isAuthorized() == false {
let loginVc = UIStoryboard("Main", bundle: nil).instantiateViewControllerWithIdentifier("Loginn") as! LoginVC
loginVc.modalTransitionStyle = .CrossDissolve
loginVc.modalPresentationStyle = .PageSheet
svc.presentViewController(loginVc, animated: true, completion: nil)
}
return true
}
虽然iPad工作正常,但iPhone会在控制台中显示消息:
对开始/结束外观转换的不平衡调用 <的Myproj。 SplitViewController:0x7fa4c9525470>
我应该如何呈现登录控制器以使该警告静音?
答案 0 :(得分:0)
为什么不把显示登录视图控制器的代码放在mainviewcontroller的viewdidappear中?
override func viewDidAppear(animated: Bool)
{
super.viewDidAppear(true)
let loginVc = UIStoryboard("Main", bundle: nil).instantiateViewControllerWithIdentifier("Loginn") as! LoginVC
loginVc.modalTransitionStyle = .CrossDissolve
loginVc.modalPresentationStyle = .PageSheet
svc.presentViewController(loginVc, animated: true, completion: nil)
}