Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on Swift Project #14

Closed
robmontesinos opened this issue Oct 13, 2014 · 5 comments
Closed

Crash on Swift Project #14

robmontesinos opened this issue Oct 13, 2014 · 5 comments

Comments

@robmontesinos
Copy link

Hi Andrea,
I'm having problems implementing AMWaveTransition on a Swift project - iOS 8 - Xcode 6.

The crash message is: -[__NSArrayI setTransform:]: unrecognized selector sent to instance 0x7fba99c5d930

the crash occurs in this method on the line: [view setTransform:CGAffineTransformMakeTranslation(delta, 0)];

Any help with this error and implementing in Swift would be greatly appreciated.

Thanks
Rob

- (void)hideView:(UIView *)view withDelay:(NSTimeInterval)delay andDelta:(float)delta
{
    void (^animation)() = ^{
        [view setTransform:CGAffineTransformMakeTranslation(delta, 0)];
        [view setAlpha:0];
    };
    void (^completion)(BOOL) = ^(BOOL finished){
        [view setTransform:CGAffineTransformIdentity];
    };
    if (self.transitionType == AMWaveTransitionTypeSubtle) {
        [UIView animateWithDuration:self.duration delay:delay options:UIViewAnimationOptionCurveEaseIn animations:animation completion:completion];
    } else if (self.transitionType == AMWaveTransitionTypeNervous) {
        [UIView animateWithDuration:self.duration delay:delay usingSpringWithDamping:0.75 initialSpringVelocity:1 options:UIViewAnimationOptionCurveEaseIn animations:animation completion:completion];
    } else if (self.transitionType == AMWaveTransitionTypeBounce){
        [UIView animateWithDuration:self.duration delay:delay options:UIViewAnimationOptionCurveEaseInOut animations:animation completion:completion];
    }
}
@andreamazz
Copy link
Owner

Hi @robmontesinos
Can I see your implementation of the visibleCells method?
My guess is that you are not properly passing an array of UIViews, so that method call is calling setTransform on an array instead.

@robmontesinos
Copy link
Author

Oh oh. You pretty damn smart. Here you go:

lazy var visibleCells: [AnyObject] = self.waveCells()

func waveCells() -> [AnyObject] {
    var cells = [AnyObject]()
    cells.append(self.mainImageView)
    cells.append(self.mainTableView.visibleCells())
    return cells
}

I wanted lazy initialization but maybe that was not the way to go.

@andreamazz
Copy link
Owner

Lazy instantiation is fine, but when you append self.mainTableView.visibleCells() you are appending an array. So your cells array looks like this: [UIImageView, NSArray]. In order for that to work you need to flatten the array. A fast way is to use the += operand instead of append:

var cells = [AnyObject]()
cells += self.mainImageView
cells += self.mainTableView.visibleCells()
return cells

@robmontesinos
Copy link
Author

Andrea, you rock!
Implementing the above caused a complaint - something about self.mainImageView and AnyObject not being a CGFloat.

This below does work thanks to you.

func waveCells() -> [AnyObject] {
    var cells = [AnyObject]()
    cells.append(self.mainImageView)
    cells += self.mainTableView.visibleCells()
    return cells
}

Salud!!!!

@andreamazz
Copy link
Owner

Happy to help 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants