订阅控制器viewWillAppear事件?

时间:2015-07-20 23:59:41

标签: ios swift uiviewcontroller ios8 lifecycle

我想将代码注册到控制器的viewWillAppear事件,以便稍后在该事件触发时触发。这可能吗?

例如,下面我想注册深度链接的代码以便稍后触发代码,否则我的代码会在viewWillAppear之前运行得太早:

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
  if let storyboard = UIApplication.sharedApplication().keyWindow?.rootViewController?.storyboard,
    let controller = storyboard.instantiateViewControllerWithIdentifier("mycontroller") as? MyControllerController {
    controller.loadData() // TOO EARLY, how to execute this in the viewWillAppear event?
  }
}

0 个答案:

没有答案