2016-01-13 41 views
0

我在我的應用程序中配置Handoff。對於以這種方式構成的應用在AppDelegate中運行一個不是第一個控制器的方法

(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

所以前面的代碼無法正常工作。我無法理解如何修改代碼...

回答

0
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 
} 
相關問題