ios - How to enable interaction in imageview on animation completion -


i using cabasic animation move uiimageview. uiimageview not detecting touches how enable user interaction after completion of animation?

[imageview setuserinteractionenabled:no]; cabasicanimation *theanimation; theanimation=[cabasicanimation animationwithkeypath:@"transform.translation.x"]; theanimation.duration=1; theanimation.repeatcount=1; theanimation.autoreverses=no;  theanimation.fromvalue=[nsnumber numberwithfloat:0]; theanimation.tovalue=[nsnumber numberwithfloat:self.view.frame.size.width/2];  theanimation.removedoncompletion = no; theanimation.fillmode = kcafillmodeforwards;  [catransaction setcompletionblock:^{     nslog(@"finished");     self.view.userinteractionenabled = true; }]; [imageview.layer addanimation:theanimation forkey:@"slide"]; [catransaction commit]; 

you can try this.

bool animationpause;  imageview = [[uiimageview alloc]initwithframe:cgrectmake(250, 300, 100, 100)];      uitapgesturerecognizer *singletap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(imageviewclicked)];     singletap.numberoftapsrequired = 1;     [imageview addgesturerecognizer:singletap];      [self.view addsubview:imageview];      imageview.image = [uiimage imagenamed:@"earth.jpeg"];      [uiview animatewithduration:1.0 animations:^{         (int = 0; i<5; i++) {              imageview.frame = cgrectmake(imageview.frame.origin.x, imageview.frame.origin.y+i+5, imageview.frame.size.width, imageview.frame.size.height)  ;             if (i==4) {                 imageview.userinteractionenabled = yes;              } if (animationpause == yes)                 [uiview setanimationdidstopselector:@selector(animatestop)];             else                 [uiview setanimationdidstopselector:@selector(resume)];         }          }     }]; 

there no need use cabasicanimation in scenario image view having frame , have added gesture or something. right when animate image go x or y based on animation requirement. dyour imageview frame having still @ initial frame. click event method called.

but yes when click on particular frame whether there imageview or not notice method called.

you have manage animationpause pausing , resuming animation. hope work. if still query let me inform


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -