ios - Doubble Tapped Gesture Not Working -
i have imageview in imageview displayed images when tapped 2 times on images not proper events.
this method not called.
- (void)doubletapwebview:(uitapgesturerecognizer *)gesture { nslog(@"double-tap"); // nothing here }
i tried code
uitapgesturerecognizer *doubletap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(doubletapwebview:)]; doubletap.numberoftapsrequired = 2; doubletap.delegate = self; [self.imgview addgesturerecognizer:doubletap]; - (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldrecognizesimultaneouslywithgesturerecognizer:(uigesturerecognizer *)othergesturerecognizer { return yes; }
and rest of code
uiscrollview *scrollview=[[uiscrollview alloc]initwithframe:cgrectmake(0, 0, 320, 480)]; [scrollview setpagingenabled:yes]; [scrollview setshowshorizontalscrollindicator:no]; frontscards=[[nsmutablearray alloc]initwithobjects:@"cloub1.png",@"cloub2.png",@"cloub3.png",@"cloub4.png", nil]; for(int m=0; m< [frontscards count];m++) { // int randidx=arc4random()%[frontscards count]; nsstring *imagename=[frontscards objectatindex:m]; nsstring *fullimagename=[nsstring stringwithformat:@"%@",imagename]; int padding=25; // padding given. cgrect imageviewframe=cgrectmake(scrollview.frame.size.width*m+padding, scrollview.frame.origin.y, scrollview.frame.size.width-2*padding, scrollview.frame.size.height); imgview=[[uiimageview alloc]initwithframe:imageviewframe]; [imgview setimage:[uiimage imagenamed:fullimagename]]; [imgview setcontentmode:uiviewcontentmodescaleaspectfill]; [scrollview addsubview:imgview]; } cgsize scrollviewsize=cgsizemake(scrollview.frame.size.width*[frontscards count], scrollview.frame.size.height); [scrollview setcontentsize:scrollviewsize]; [self.view addsubview:scrollview];
help me out this.thanks in advance.
by default imageview userinteractio false can add line of code.
self.imgview.userinteractionenabled=yes;
and add uigesturerecognizerdelegate
in .h file
Comments
Post a Comment