运行 AppDelegate 中用于控制器的方法,这不是第一个
Run a method in AppDelegate for a Controller which is not the first
我正在我的应用程序中配置 Handoff。对于以这种方式构建的应用
(Entry Point)
-> UINavigationController
->
InterestedViewController
够了:
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
if let win = self.window {
let navController = win.rootViewController as! UINavigationController
let viewController = navController.topViewController as! myViewController
viewController.restoreUserActivityState(userActivity)
}
return true
}
当使用 Handooff 启动应用程序时,AppDelegate 中的此方法 运行 和 "myViewController" 中的启动方法 func restoreUserActivityState(activity: NSUserActivity)
一切正常。
问题是我的应用程序以另一种方式构建:
(Entry Point)
-> Another ViewController with animated logo
-> UINavigationController
-> InterestedViewController
所以前面的代码不起作用。我不明白如何调整代码...
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool { // Handoff
if let win = window {
let presentationController = win.rootViewController as! PresentationController
let navController = presentationController.presentedViewController as! UINavigationController
let viewController = navController.topViewController as! myViewController
viewController.restoreUserActivityState(userActivity)
}
return true
}
我正在我的应用程序中配置 Handoff。对于以这种方式构建的应用
(Entry Point)
->UINavigationController
->InterestedViewController
够了:
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
if let win = self.window {
let navController = win.rootViewController as! UINavigationController
let viewController = navController.topViewController as! myViewController
viewController.restoreUserActivityState(userActivity)
}
return true
}
当使用 Handooff 启动应用程序时,AppDelegate 中的此方法 运行 和 "myViewController" 中的启动方法 func restoreUserActivityState(activity: NSUserActivity)
一切正常。
问题是我的应用程序以另一种方式构建:
(Entry Point)
->Another ViewController with animated logo
->UINavigationController
->InterestedViewController
所以前面的代码不起作用。我不明白如何调整代码...
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool { // Handoff
if let win = window {
let presentationController = win.rootViewController as! PresentationController
let navController = presentationController.presentedViewController as! UINavigationController
let viewController = navController.topViewController as! myViewController
viewController.restoreUserActivityState(userActivity)
}
return true
}