ios - UIImageView touch handling -


i have image view background image. seeking in place on image view touches enabled. started this:

- (id)initwithtouchpoint:(cgrect )point {     self = [super init];     if (self) {         touchframe = point;         [self setaccessibilityframe:touchframe];     }     return self; }  /* // override drawrect: if perform custom drawing. // empty implementation adversely affects performance during animation. - (void)drawrect:(cgrect)rect {     // drawing code } */  -(bool)canresignfirstresponder{     return yes; }  -(void)touchesbegan:(nsset *)touches withevent:(uievent *)event{     uitouch *touch = [[event alltouches] anyobject];     cgpoint touchlocation = [touch locationinview:self];      if (cgrectcontainspoint(touchframe, touchlocation)) {         //[self setuserinteractionenabled:no];      }else{         //[self setuserinteractionenabled:yes];     }      dlog(@"touchesbegan @ x : %f y : %f",touchlocation.x,touchlocation.y); }  -(void)touchesmoved:(nsset *)touches withevent:(uievent *)event{  }  -(void)touchesended:(nsset *)touches withevent:(uievent *)event{  } 

is possible let user touch on image view when user touches in touchframe ?

thank you.

add uitapgesturerecognizer on uiimageview

uitapgesturerecognizer *gesture = [[uitapgesturerecognizer alloc] initwithtarget:self                                                                           action:@selector(handlegesture:)]; [gesture setnumberoftapsrequired:1]; [imageview setuserinteractionenabled:yes]; [imageview addgesturerecognizer:gesture]; 

now within handlegesture method :

-(void)handlegesture:(uitapgesturerecognizer *)_gesture {      if (_gesture.state == uigesturerecognizerstateended)      {          cgpoint touchedpoint = [_gesture locationinview:self.view];      } } 

you can check wether touchedpoint within handlegesture method in specified area or not , can perform desired task accordingly


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -