0
votes

I am using CSStickyHeaderFlowLayout for Parallax Header in Swift. Xcode 7 swift 2.0 .

I tested the github swift demo. The app crashed when segueing to another view controller. The log said:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'great1'

I also tested the github object-c demo code , segue works fine .

I found out the code below has the problem . it's in appDelegate.swift for the swift demo code in the repository . Does anyone know the solution keeping segue working while having stickyParallaxHeader like the pic below .

[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
    }

below is the debug log .

    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
1
You need to give more information about which version of Xcode you're using and from which screen to which you're getting the error. You would need to debug and narrow down the issue. Check here to know how: raywenderlich.com/10209/my-app-crashed-now-what-part-1 - manman
I am using Xcode 7.0.1 swift 2 . I did not use any specific code , just tested the demo code from github as the 2nd link . All you need to do is just add a view controller and new segue on top of swift 2 demo code . Then the error pops up and app crashed . I also tested the obje-c demo code from the same repository , no problem on segue . thanks for editing to my original question. I learned how to do in the future . - Richard Mao
S you would need to update the question with info about the tools that you're using and some code of how you added the segue. Clearly, there's something wrong with the way that you added the segue - manman
I have researched for long time . The problem is some code in app delegate.swift original from swift demo code in the repository . Pls see my revised question . - Richard Mao
There's something wrong with the segue that you've added. Check the segue identifier and if possible, send snapshots or explain how you created that segue. - manman

1 Answers

1
votes

I finally sort it out .

  1. Remove the above code from project, keep

    func application(application: UIApplication, didFinishLaunchingWithOptions  launchOptions: [NSObject: AnyObject]?) -> Bool { return true }
    
  2. Make sure the layout class is CSStickyHeaderFlowLayout, see the image below .

enter image description here enter image description here