我正在快速为我的 iOS 9 应用程序实现一些 3D 触摸快速操作,我有一个奇怪的问题。当我的应用程序在后台并且我以快速操作启动时,一切都按计划进行。当我的应用程序完全死机时(即我从多任务菜单中杀死了它),并且我以快速操作启动时,应用程序崩溃了。我在调试时遇到了麻烦,因为一旦我终止应用程序,Xcode 中的调试会话就会分离。有没有办法让我像往常一样连接到应用程序进行调试,或者我的代码中有什么东西会导致它?提前致谢。
代码:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
var launchedFromShortCut = false
//Check for ShortCutItem
if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsShortcutItemKey] as? UIApplicationShortcutItem
{
launchedFromShortCut = true
self.handleShortCutItem(shortcutItem)
}
return !launchedFromShortCut
}
func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void)
{
self.handleShortCutItem(shortcutItem)
}
func handleShortCutItem(shortcutItem: UIApplicationShortcutItem)
{
//Get type string from shortcutItem
if let shortcutType = ShortcutType.init(rawValue: shortcutItem.type)
{
//Get root navigation viewcontroller and its first controller
let rootNavigationViewController = window!.rootViewController as? UINavigationController
if let rootViewController = rootNavigationViewController?.viewControllers.first as! LaunchViewController?
{
//Pop to root view controller so that approperiete segue can be performed
rootNavigationViewController?.popToRootViewControllerAnimated(false)
switch shortcutType
{
case .Compose:
rootViewController.shouldCompose()
break
}
}
}
}
谢谢!