ios - UIImage/UIView Animation cycles images too fast, need to slow it down -


i've got image slideshow animation in app, standard seems go ridiculously fast, i'm not sure why default speed. anyway need way of slowing down. speed of animation fine, each image doesn't stay on screen long enough @ all! appreciated.

- (void)animateimages { static int count = 0; nsarray *animationimages =@[[uiimage imagenamed:@"blur_edges.png"],                             [uiimage imagenamed:@"blur_edges2.png"],                             [uiimage imagenamed:@"blur_edges3.png"],                             [uiimage imagenamed:@"blur_edges4.png"],                             [uiimage imagenamed:@"slide8.png"]]; uiimage *image = [animationimages objectatindex:(count % [animationimages count])]; [uiview transitionwithview:_imview                   duration:1.5                 options:uiviewanimationoptiontransitioncrossdissolve                 animations:^{                     _imview.image = image;                 } completion:^(bool finished) {                     [self animateimages];                     count++;                 }]; } 

i this:

@interface myobject : nsobject {     uiimageview * _imview ; } @end  @implementation myobject  const nstimeinterval ktimebetweenslides = 3.0 ;  -(void)nextimagetimerfired:(nstimer*)timer {     nsenumerator * enumerator = [ timer userinfo ] ;     [ self nextimage:enumerator ] ; }  -(void)nextimage:(nsenumerator*)enumerator {     uiimage * nextimage = [ enumerator nextobject ] ;     if ( nextimage != nil )     {         [uiview transitionwithview:_imview duration:1.5 options:uiviewanimationoptiontransitioncrossdissolve animations:^{             _imview.image = nextimage;         } completion:nil ];         [ nstimer scheduledtimerwithtimeinterval:ktimebetweenslides target:self selector:@selector( nextimagetimerfired: ) userinfo:enumerator repeats:no ] ;     } }  -(void)animateimages {     nsarray * images = @[                  [uiimage imagenamed:@"blur_edges.png"],                  [uiimage imagenamed:@"blur_edges2.png"],                  [uiimage imagenamed:@"blur_edges3.png"],                  [uiimage imagenamed:@"blur_edges4.png"],                  [uiimage imagenamed:@"slide8.png"]                  ] ;      nsenumerator * enumerator = [ images objectenumerator ] ;     [ self nextimage:enumerator ] ; }  @end 

this creates enumerator can use walk through array of images. kick off process calling -nextimage:. pulls next image enumerator, schedules timer call after delay. timer handler calls -nextimage: again display next image. process repeats until enumerator empty.

you use array of images names instead of image objects, depending how large images are.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -