ios - Constricting UISwipeGestureRecognizer to only detect swipes within the area of a IUImageView -
i using following code detect swipe gestures in app:
- (ibaction)swipermethod:(uiswipegesturerecognizer *)sender { _sampletext.text=@"hi"; } - (void)viewdidload { [super viewdidload]; uiswipegesturerecognizer *leftrecognizer = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(swipermethod:)]; [leftrecognizer setdirection: uiswipegesturerecognizerdirectionleft]; [[self view] addgesturerecognizer:leftrecognizer]; // additional setup after loading view, typically nib. }
however, want restrict swipe recognition portion of screen defined uimageview. there simple way this? thanks.
if know uiimageview is, can test whether gesture inside area:
- (bool)pointinside:(cgpoint)point{ return (point.y < imageviewbottom && point.y > imageviewtop && point.x < imageviewright && point.x > imageviewleft); }
if gesture outside uiimageview ignore it.
Comments
Post a Comment