Search code examples
objective-ciosipad

UIView beginAnimations fails on selector


[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:4];
[UIView setAnimationDuration:5];
navigation.frame = CGRectOffset(navigation.frame, 0, 430);
[UIView commitAnimations];

Code block above works fine when called manually on viewDidLoad function or with button tap. But when i try to call that block within a selector function like below, animation doesnt effect. Object jumps to position. What would cause to that?

if ([delegate respondsToSelector:@selector(carouselDidEndScrollingAnimation:)])
{
    [delegate carouselDidEndScrollingAnimation:self];
}


- (void) carouselDidEndScrollingAnimation:(iCarousel *)carousel{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:5];
    navigation.frame = CGRectOffset(navigation.frame, 0, 430);
    [UIView commitAnimations];
}

icarousel github


Solution

  • Still don't know the real problem but

    [self performSelector:@selector(makeAnim) withObject:nil afterDelay:0.0001];
    

    solved my problem.

    Hope helps anyone.

    Still needs a better solution.