2015-10-27 23 views
0

我正在使用CSStickyHeaderFlowLayout作爲Swift中的視差標題。 Xcode 7 swift 2.0。CSStickyHeaderFlowLayout快速接收器沒有標識符的繼續播放

我測試了github swift demo。當轉到另一個視圖控制器時,該應用程序崩潰。 日誌說:

終止應用程序由於未捕獲的異常「NSInvalidArgumentException」,原因:「接收器()具有標識符沒有賽格瑞‘great1’

我還測試了GitHub的對象的C演示代碼,segue工作正常。

我發現下面的代碼有問題。它在appDelegate.swift中用於存儲庫中的swift演示代碼。有誰知道解決方案保持繼續工作,同時像下面的圖片stickyParallaxHeader。

[enter image description here] [enter image description here]下面

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
     // Override point for customization after application launch. 

     let stickyHeaderFlowLayout = CSStickyHeaderFlowLayout() 
     let collectionViewController = CollectionViewController(collectionViewLayout: stickyHeaderFlowLayout) 

     let window = UIWindow(frame: UIScreen.mainScreen().bounds) 
     window.rootViewController = collectionViewController 
     window.makeKeyAndVisible() 
     self.window = window 
     return true 
    } 

是調試日誌。

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<collectionviewmapdemo.CollectionViewController: 0x7fdbdb01d600>) has no segue with identifier 'great1'' 
*** First throw call stack: 
(
    0 CoreFoundation      0x0000000108d50f65 __exceptionPreprocess + 165 
    1 libobjc.A.dylib      0x0000000109116deb objc_exception_throw + 48 
    2 UIKit        0x0000000107919692 -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0 
    3 collectionviewmapdemo   0x00000001051a6ba7 _TFC25collectionviewmapdemo24CollectionViewController14collectionViewfS0_FTCSo16UICollectionView24didSelectItemAtIndexPathCSo11NSIndexPath_T_ + 135 
    4 collectionviewmapdemo   0x00000001051a6c2f _TToFC25collectionviewmapdemo24CollectionViewController14collectionViewfS0_FTCSo16UICollectionView24didSelectItemAtIndexPathCSo11NSIndexPath_T_ + 79 
    5 UIKit        0x0000000107f91eb0 -[UICollectionView _selectItemAtIndexPath:animated:scrollPosition:notifyDelegate:] + 701 
    6 UIKit        0x0000000107fb2d51 -[UICollectionView touchesEnded:withEvent:] + 574 
    7 UIKit        0x0000000107988663 forwardTouchMethod + 349 
    8 UIKit        0x000000010798872c -[UIResponder touchesEnded:withEvent:] + 49 
    9 UIKit        0x0000000107988663 forwardTouchMethod + 349 
    10 UIKit        0x000000010798872c -[UIResponder touchesEnded:withEvent:] + 49 
    11 UIKit        0x0000000107c3dca5 _UIGestureRecognizerUpdate + 10289 
    12 UIKit        0x00000001077f7592 -[UIWindow _sendGesturesForEvent:] + 1137 
    13 UIKit        0x00000001077f8681 -[UIWindow sendEvent:] + 849 
    14 UIKit        0x00000001077aa752 -[UIApplication sendEvent:] + 263 
    15 UIKit        0x0000000107785fcc _UIApplicationHandleEventQueue + 6693 
    16 CoreFoundation      0x0000000108c7d0a1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 
    17 CoreFoundation      0x0000000108c72fcc __CFRunLoopDoSources0 + 556 
    18 CoreFoundation      0x0000000108c72483 __CFRunLoopRun + 867 
    19 CoreFoundation      0x0000000108c71e98 CFRunLoopRunSpecific + 488 
    20 GraphicsServices     0x000000010b240ad2 GSEventRunModal + 161 
    21 UIKit        0x000000010778b676 UIApplicationMain + 171 
    22 collectionviewmapdemo   0x00000001051b555d main + 109 
    23 libdyld.dylib      0x0000000109c3f92d start + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
+0

您需要哪個的Xcode的版本你使用並從屏幕到你得到的錯誤給出更多的信息。您需要調試並縮小問題範圍。檢查這裏知道如何:http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1 – manman

+0

我使用Xcode 7.0.1 swift 2。我沒有使用任何特定的代碼,只是測試了來自github的演示代碼作爲第二個鏈接。您只需在swift 2 demo代碼上添加視圖控制器和新的segue即可。然後錯誤彈出,應用程序崩潰。我還測試了來自同一個存儲庫的obje-c演示代碼,在segue上沒有問題。感謝編輯我的原始問題。我學會了將來如何去做。 –

+0

S您需要更新問題,並提供有關您正在使用的工具的信息以及您如何添加segue的一些代碼。很明顯,您添加我長期研究的segue – manman

回答

1

我終於整理出來了。

  1. 從項目中刪除上述代碼中,保持

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { return true } 
    
  2. 確保佈局類是CSStickyHeaderFlowLayout,見下圖。

enter image description here enter image description here

相關問題