xcode - pausing timer,uiview animation and audio iOS -
i have viewcontroller playing sound using avaudioplayer
, timer running 2 minutes using nstimer
, sequence of animation being played using
[uiview animatewithduration:2.0 delay:0.0 options:uiviewanimationoptioncurvelinear animations:^{ //rolling man's tongue out _cooling2manimage.alpha = 1.0; _cooling3manimage.alpha = 0.0; } completion:^(bool boolvalue){ [uiview animatewithduration:2.0 delay:0.0 options:uiviewanimationoptioncurvelinear animations:^{ //showing arrow image , translating arrow mouth _cooling1arrowimage.alpha = 1.0; _cooling1arrowimage.transform = cgaffinetransformmaketranslation(0,-110); } completion:^(bool boolvalue){ [uiview animatewithduration:1.5 delay:0.0 options:uiviewanimationoptioncurvelinear animations:^{ //hiding arrow _cooling1arrowimage.alpha = 0.0; } completion:^(bool boolvalue){ _cooling1arrowimage.transform = cgaffinetransformmaketranslation(0,0); [uiview animatewithduration:2.0 delay:0.0 options:uiviewanimationoptioncurvelinear animations:^{ //roll tongue in _cooling2manimage.alpha = 0.0; _cooling3manimage.alpha = 1.0; } completion:^(bool boolvalue){ //show arrow , translate [uiview animatewithduration:2.0 delay:0.0 options:uiviewanimationoptioncurvelinear animations:^{ _cooling3arrowimage.alpha = 1.0; cgaffinetransform scale; cgaffinetransform translate; scale = cgaffinetransformmakescale(2.5, 2.5); translate = cgaffinetransformmaketranslation(0, 40); _cooling3arrowimage.transform = cgaffinetransformconcat(scale, translate); _cooling3arrowimage.alpha = 0.0; } completion:^(bool boolvalue){ [uiview animatewithduration:2.0 delay:0.0 options:uiviewanimationoptioncurvelinear animations:^{ _cooling2manimage.alpha = 0.0; _cooling3manimage.alpha = 1.0; _cooling1arrowimage.alpha = 0.0; _cooling3arrowimage.alpha = 0.0; _cooling3arrowimage.transform = cgaffinetransformmaketranslation(0,0); _cooling3arrowimage.transform = cgaffinetransformmakescale(1,1); if (count <= 6 ) { [self startanimation1]; count += 1; nslog(@"%i",count); } } completion:nil]; }]; }]; }]; }]; }];
i ahve implement pause , resume functionality when user hits "pause" button ,the audio ,the animation , timer pauses , when user hits resume button resumes paused.can let me know how can achieve this?
for avaudioplayer use
[avplayerobject pause]; [avplayerobject play]; timer:
you can store amount of time has passed since timer started... when timer starts store date in nsdate variable. when user switches... use method timeintervalsincenow in nsdate class store how time has passed... note give negative value timeintervalsincenow. when user returns use value set appropriate timer.
for view animations check one