objective c - iOS Add tap Gesture to UIImageView -


i have image inside uiimageview, has gesture zooming, can see code.

i want able insert clickable areas of image, not screen, if click image point minimum or maximum zoom zoom return same value.

i tell uigesturerecognizer if can do? why can not figure out whether work or not.

thanks

my code:

uitapgesturerecognizer *twofingertap = [[uitapgesturerecognizer alloc] initwithtarget:self         action:@selector(handletwofingertap:)]; [twofingertap setnumberoftouchesrequired:2]; [img addgesturerecognizer:twofingertap]; float minimumscale = 0.4;//this minimum scale, set whatever want. 1.0 = default scroll.maximumzoomscale = 4.0; scroll.minimumzoomscale = minimumscale; scroll.zoomscale = minimumscale; [scroll setcontentmode:uiviewcontentmodescaleaspectfit]; [img sizetofit]; [scroll setcontentsize:cgsizemake(img.frame.size.width, img.frame.size.height)];  [control setselectedsegmentindex:0]; [control addtarget:self             action:@selector(action:)   forcontrolevents:uicontroleventvaluechanged];  //this recognizer on image uigesturerecognizer *recognizerimage = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(tapimage:)]; [(uitapgesturerecognizer *)recognizer setnumberoftapsrequired:2]; [img addgesturerecognizer:recognizer]; }   - (void)tapimage:(uitapgesturerecognizer *)recognizer {      cgpoint location = [recognizer locationinview:self.view];     nslog(@"x %f y %f",location.x, location.y); } 

try using imageview reference:

cgpoint location = [recognizer locationinview:recognizer.view]; 

let me know if works.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -