SwiftKickMobile / TLLayoutTransitioning

Enhanced transitioning between UICollectionView layouts in iOS.
MIT License
355 stars 47 forks source link

-[UICollectionViewTransitionLayout setToContentOffset:]: unrecognized selector #10

Closed wanderingme closed 10 years ago

wanderingme commented 10 years ago

This library is super helpful! Thank you so much! But I'm getting this bug suddenly:

"[UICollectionViewTransitionLayout setToContentOffset:]: unrecognized selector sent to instance 0x146f8360"

Specifically my stack trace breaks at the following line in your example:

"layout.toContentOffset = toOffset;"

If I comment it out, everything works fine, except, obviously, I no longer get that awesome offset during transitions. The problem, as best as I can tell, is that the following line of code is returning a [UICollectionViewTransitionLayout] and therefore isn't being properly typed to your [TLTransitionLayout] subclass for some reason:

"TLTransitionLayout layout = (TLTransitionLayout )[collectionView transitionToCollectionViewLayout:toLayout duration:2 easing:QuarticEaseInOut completion:nil];"

When I NSLog the 'layout' object, it's definitely a [UICollectionViewTransitionLayout] type, not [TLTransitionLayout]. And, obviously, the [UICollectionViewTransitionLayout] class doesn't have the property "toOffset" I need, hence the error I'm experiencing. I've searched all over since this problem popped up over 9 hours ago, and zero solutions have helped. I've ensured all headers are included with #import and the implementation files are all being compiled within the correct target. I've cleared all my Derived Data, etc. Even uninstalled and reinstalled Xcode. I'm certainly lost. It just stopped working suddenly. I know it must be PEBKAC, but I can't for the life of me figure out how that can be. :( Anyhow, thanks a bunch for any insight. It was spectacular when it was working for me. :)

wtmoose commented 10 years ago

Hi there,

I think this is an easy one.

The collection view delegate is responsible for vending the transition layout, so make sure you've got something like this and it's getting called:

- (UICollectionViewTransitionLayout *)collectionView:(UICollectionView *)collectionView transitionLayoutForOldLayout:(UICollectionViewLayout *)fromLayout newLayout:(UICollectionViewLayout *)toLayout
{
    NSArray *supplementaryKinds = ...; // optional supplementary view kinds
    return [[TLTransitionLayout alloc] initWithCurrentLayout:fromLayout nextLayout:toLayout supplementaryKinds:supplementaryKinds];
}
wanderingme commented 10 years ago

I spent all day in my coding k-hole yesterday trying to figure out why this wasn't working, and not once did it dawn on me that maybe, just maybe, it was that method I deleted. I've been on a coding binge and my brain is fried. I think I need to take a break. Thanks a bunch for your help. That work perfectly.

wtmoose commented 10 years ago

Hey, I know that feeling! Glad it worked for you.

Tim

On Jul 11, 2014, at 1:34 PM, wanderingme notifications@github.com wrote:

I spent all day in my coding k-hole yesterday trying to figure out why this wasn't working, and not once did it dawn on me that maybe, just maybe, it was that method I deleted. I've been on a coding binge and my brain is fried. I think I need to take a break. Thanks a bunch for your help. That work perfectly.

— Reply to this email directly or view it on GitHub.