Monday, 15 June 2015

ios - function does not work until I click on the screen during run time -



ios - function does not work until I click on the screen during run time -

i want show animated image 1 time view loaded few seconds hide , view 2 other images, have used array animate image set timer phone call function ontimer repeatedly ,inside function check if image animated once, if stop timer , view 2 other images

it works fine when run project except 2 images not appear until click on screen!

her code:

- (void)viewdidload { [super viewdidload]; // additional setup after loading view. outline.animationimages = [nsarray arraywithobjects: [uiimage imagenamed:@"traffic.png"], [uiimage imagenamed:@"red.png"], [uiimage imagenamed:@"yellow.png"], [uiimage imagenamed:@"green.png"], nil]; [outline setanimationrepeatcount:1]; outline.animationduration = 4; [outline startanimating]; timer = [nstimer scheduledtimerwithtimeinterval: 1.0/30.0 target:self selector:@selector(ontimer) userinfo:nil repeats:yes]; } -(void) ontimer { if (![outline isanimating] == true){ // if animation has been played once, nslog(@"animation stopped, something"); rannan.image = [uiimage imagenamed:@"rannan.png"]; outline.image = [uiimage imagenamed: @"outline.png"]; [ timer invalidate]; // } }

it looks reason isanimating not set true until click on screen when project running

hope find reply 1 :)

i wonder why fire timer every 1/30 of second. set animation 4 seconds can fire timer after 4 seconds.

a way check if view no longer animating:

calayer *presentationlayer = (calayer*)outline.layer.presentationlayer; if(![presentationlayer animationkeys]) { nslog(@"animation stopped, something"); }

ios xcode ipad nstimer

No comments:

Post a Comment