0

i have scrollview, which has zoomscale property inside uiview begin animation,it animates well for some duration,but in between these animations i want to pause the animation and resume the animation,please help me out of this

[UIView beginAnimations:@"anim1" context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:fanim];
z = [[arrImage1 objectAtIndex:1] floatValue];
scroll.zoomScale = z;
NSLog(@"   %f",scroll.zoomScale);
if (iw != 0 || ih != 0) 
{
    image1.frame = CGRectMake(0, 0, iw,ih);
}
z = [[arrImage2 objectAtIndex:1] floatValue];
scroll1.zoomScale = z;
z = [[arrImage3 objectAtIndex:1] floatValue];
scroll2.zoomScale = z;
[UIView commitAnimations];
Dharmbir Singh
  • 17,485
  • 5
  • 50
  • 66
Ahamed Aathil
  • 97
  • 1
  • 1
  • 6
  • You can refer the following : http://stackoverflow.com/questions/3211065/how-to-pause-and-resume-uiview-animation and http://stackoverflow.com/questions/9104487/how-to-pause-and-resume-uiview-animation-without-block-animation – V-Xtreme Apr 08 '13 at 05:16

1 Answers1

0

That is possible by using nstimer. Try using nstimer for starting and pausing animation here is a set of code which you can use. Implement your animation within a method and use the nstimer to fire it and pause it:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self startTimer];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self stopTimer];
}

- (void)startTimer {
    NSTimer *timer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:3.0] interval:3.0 target:self selector:@selector(this is where your animation method name goest) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
    self.animationmethodename = timer;
    [timer release];
}

- (void)stopTimer {
    [self.animationmethodname invalidate];
    self.animationmethodtimer = nil;
}

Then replace the animationmethodname with the name of the method you are using to create the animation.

Adrian P
  • 6,479
  • 4
  • 38
  • 55
  • can u please tell what is animationmethodtimer? – Ahamed Aathil Apr 08 '13 at 05:41
  • u mean startTimer method? – Ahamed Aathil Apr 08 '13 at 05:42
  • The Animation method name is the method that you use to implenet the code you show in your question. I guess you probably put that set of code in viewdidload, if so then you can remove it and create a -(void) method and whatever name you place after that would be what you replace animationmethodname with. – Adrian P Apr 08 '13 at 05:46