func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
let splitController = self.window?.rootViewController as! UISplitViewController
let navigationController = splitController.viewControllers.first as! UINavigationController
navigationController.topViewController?.restoreUserActivityState(userActivity)
return true
}
接下来,在MasterViewController类里实现restoreUserActivityState方法:
override func restoreUserActivityState(activity: NSUserActivity) {
if let name = activity.userInfo?["name"] as? String,
let genre = activity.userInfo?["genre"] as? String,
let time = activity.userInfo?["time"] as? NSDate {
let show = Show(name: name, genre: genre, time: time)
self.showToRestore = show
self.performSegueWithIdentifier("showDetail", sender: self)
}
else {
let alert = UIAlertController(title: "Error", message: "Error retrieving information from userInfo:\n\(activity.userInfo)", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Dismiss", style: .Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
}
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-51781-3.html
芝麻糊里面都是密封包装
IS就是美国培育的
再横起来也不迟