2016-03-29 91 views
0

當我試圖使用ApplicationshortcutItem導航到視圖控制器時,我的應用程序立即崩潰。 但是,我的其他應用程序快捷方式(1 viewcontroller更多)不會顯示此行爲。 導航到相同的視圖控制器不起作用,不會使其崩潰。使用ApplicationShortCut SIGTRAP時發生崩潰

我崩潰:在Appdelegate

Thread 0 name: Dispatch queue: com.apple.main-thread 
Thread 0 Crashed: 
0 libswiftCore.dylib    0x000000010064e5dc 0x100510000 + 1304028 
1 PayDay!       0x000000010011166c 0x1000e0000 + 202348 
2 PayDay!       0x00000001001126a4 0x1000e0000 + 206500 
3 UIKit       0x0000000186c42f40 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 692 
4 UIKit       0x0000000186c430a8 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80 
5 UIKit       0x0000000186c321a8 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2360 
6 UIKit       0x0000000186c47b74 -[UITableView _performWithCachedTraitCollection:] + 104 
7 UIKit       0x00000001869d87ac -[UITableView layoutSubviews] + 176 
8 UIKit       0x00000001868e80e4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 656 
9 QuartzCore      0x000000018428ea28 -[CALayer layoutSublayers] + 148 
10 QuartzCore      0x0000000184289634 CA::Layer::layout_if_needed(CA::Transaction*) + 292 
11 UIKit       0x00000001868fefa4 -[UIView(Hierarchy) layoutBelowIfNeeded] + 924 
12 UIKit       0x00000001869ad57c -[UINavigationController _layoutViewController:] + 1196 
13 UIKit       0x00000001869aaf54 -[UINavigationController _layoutTopViewController] + 228 
14 UIKit       0x00000001869c3cc0 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 728 
15 UIKit       0x00000001869c39ac -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 416 
16 UIKit       0x00000001869c36b4 -[UINavigationTransitionView _cleanupTransition] + 744 
17 UIKit       0x0000000186927b10 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 312 
18 UIKit       0x0000000186925d8c +[UIViewAnimationState popAnimationState] + 324 
19 UIKit       0x00000001869b711c -[UINavigationTransitionView transition:fromView:toView:] + 1792 
20 UIKit       0x00000001869acc30 -[UINavigationController _startTransition:fromViewController:toViewController:] + 2696 
21 UIKit       0x00000001869abddc -[UINavigationController _startDeferredTransitionIfNeeded:] + 868 
22 UIKit       0x00000001869aba04 -[UINavigationController __viewWillLayoutSubviews] + 60 
23 UIKit       0x00000001869ab96c -[UILayoutContainerView layoutSubviews] + 208 
24 UIKit       0x00000001868e80e4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 656 
25 QuartzCore      0x000000018428ea28 -[CALayer layoutSublayers] + 148 
26 QuartzCore      0x0000000184289634 CA::Layer::layout_if_needed(CA::Transaction*) + 292 
27 QuartzCore      0x00000001842894f4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32 
28 QuartzCore      0x0000000184288b24 CA::Context::commit_transaction(CA::Transaction*) + 252 
29 QuartzCore      0x000000018428886c CA::Transaction::commit() + 512 
30 QuartzCore      0x0000000184281dd8 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 80 
31 CoreFoundation     0x00000001817587b0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32 
32 CoreFoundation     0x0000000181756554 __CFRunLoopDoObservers + 372 
33 CoreFoundation     0x0000000181680d30 CFRunLoopRunSpecific + 416 
34 UIKit       0x000000018695b834 -[UIApplication _run] + 460 
35 UIKit       0x0000000186955f70 UIApplicationMain + 204 
36 PayDay!       0x00000001001262dc 0x1000e0000 + 287452 
37 libdyld.dylib     0x000000018121e8b8 start + 4 

方法來顯示視圖控制器:

if let rootViewController = window?.rootViewController, let shortcutItemType = DGShortcutItemType(shortcutItem: shortcutItem) { 
      rootViewController.dismissViewControllerAnimated(false, completion: nil) 
      switch shortcutItemType { 
      case .Message: 
       let storyboard = UIStoryboard(name: "Main", bundle: nil) 
       let rootTabbarController = self.window?.rootViewController as! UITabBarController 
       let firstNav = storyboard.instantiateViewControllerWithIdentifier("NavController") as! UINavigationController 
       rootTabbarController.viewControllers![0] = firstNav 
       let VC1 = storyboard.instantiateViewControllerWithIdentifier("PeriodeView") 
       let VC2 = storyboard.instantiateViewControllerWithIdentifier("weekViewController") 
       let VC3 = storyboard.instantiateViewControllerWithIdentifier("timesInsertViewController") 
       firstNav.viewControllers.insert(VC1, atIndex: 1) 
       firstNav.viewControllers.insert(VC2, atIndex: 2) 
       firstNav.pushViewController(VC3, animated: false) 
       break 
      case .Time: 
       let storyboard = UIStoryboard(name: "Main", bundle: nil) 
       let rootTabbarController = self.window?.rootViewController as! UITabBarController 
       let firstNav = storyboard.instantiateViewControllerWithIdentifier("NavController") as! UINavigationController 
       rootTabbarController.viewControllers![0] = firstNav 
       let VC1 = storyboard.instantiateViewControllerWithIdentifier("PeriodeView") 
       let VC2 = storyboard.instantiateViewControllerWithIdentifier("weekViewController") 
       firstNav.viewControllers.insert(VC1, atIndex: 1) 
       firstNav.pushViewController(VC2, animated: false) 

       // Display an alert indicating the shortcut selected from the home screen. 
       break 
      } 
     } 

case .Time被調用運行。

該視圖顯示一個tableview並使用全局變量'pressedYYY',該名稱在導航到viewController之前設置。 我的應用程序委託也設置這個非常相同的變量。

我該如何解決這個問題?因爲我不能清楚地看到它出錯的地方

回答

0

我已經能夠找出問題。 由於我之前沒有訪問我的控制檯(不得不殺死應用程序),我改變了我的方案,並確保我在UIApplicationShortcut上首次啓動應用程序時有調試工具的權限。

我做了以下內容: 我選擇我的設備,並點擊「編輯計劃」 enter image description here

這將告訴你以下結果: enter image description here

如果按'等待可執行上馬'你可以完全殺死該應用程序,只需要連接調試器就可以運行它。

原來我的應用程序卡住了,因爲一個變量得到了設定,但隨後奇蹟般地被設置爲""這使得應用程序崩潰,因爲它不能轉換""Int。 我將不得不考慮這個問題,但不是。它是固定的!