我正在为我的iOS 9应用在swift中实施一些3D触摸快速操作,并且我有一个奇怪的问题。当我的应用程序处于后台并且我使用快速操作启动时,一切都按计划进行。当我的应用程序完全死亡(即我从多任务菜单中杀死它),并且我以快速操作启动时,应用程序崩溃。我在调试时遇到了麻烦,因为一旦我终止了应用程序,Xcode中的调试会话就会被分离。有没有办法让我连接到应用程序进行调试像正常,或者是否有我的代码中会导致它的东西?提前致谢。使用UIApplicationShortcutItem启动
代码:
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
}
}
}
}
谢谢!
你可以在死后看应用程序的崩溃日志文件... –
你得到这个排序,我有同样的问题? – theiOSDude
@theiOSDude不,我没有。 –