iphone - animateWithDuration not working correctly -


i have written code had hoped randomly spin block view on screen, pause, spin out. action should repeat in semi random fashion. kinda of works in shows block, spins out, shows again after time however:

  • it not spin in (it spins out)
  • it never changes position

what vital thing missing code?

-(void)randomlyshowblock{     int randomtime = 1 + arc4random() % (3 - 1);      [randomblock setneedsdisplay];      dispatch_after(dispatch_time(dispatch_time_now, randomtime * nsec_per_sec), dispatch_get_main_queue(), ^(void){          int randomx = 10 + arc4random() % ((int)self.view.frame.size.width - 10);         int randomy = 10 + arc4random() % ((int)self.view.frame.size.height - 10);          randomblock.frame = cgrectmake(randomx, randomy, randomblock.frame.size.width, randomblock.frame.size.height);          [uiview animatewithduration:0.4 delay:0 options:uiviewanimationoptioncurveeaseinout                          animations:^(void) {                              randomblock.transform = cgaffinetransformmakerotation(degreestoradians(-90));                              randomblock.backgroundcolor = [[uicolor alloc] initwithred:50.0/255.0 green:124.0/255.0 blue:203.0/255.0 alpha:1.0];                          }                          completion:^(bool finished){                              [uiview animatewithduration:0.4 delay:1 options:uiviewanimationoptioncurveeaseinout                                               animations:^(void) {                                                   randomblock.transform = cgaffinetransformmakerotation(degreestoradians(0));                                                   randomblock.backgroundcolor = [[uicolor alloc] initwithred:220.0/255.0 green:220.0/255.0 blue:220.0/255.0 alpha:0];                                               }                                               completion:^(bool finished){                                                   nslog(@"finished animation");                                                   //model                                                    [self randomlyshowblock];                                               }];                          }];     }); } 

you're not changing frame in animation, it's not surprising it's not moving.

as spinning, guess transform not identity transform, rather nil one, , ios doesn't know how animate nothing something. try setting it, before animation block, cgaffinetransformidentity.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -