ios - UILongPressGestureRecognizer bound only applicable on UIImageView -
this question has answer here:
i'm developing ios app based on augmented reality. suppose user set distance wall through uislider
. he'll select picture gallery , see how on wall. app should scale uiimage
accordingly distance of user wall , user can drag see how on wall.
i want apply uilongpressgesturerecognizer
on added uiimage
can deleted i.e. tap hold , delete.
this code i've applied import image in library i'll import gallery later:
self.myimage = [uiimage imagenamed:@"myimage.png"]; self.myimageview = [[uiimageview alloc] initwithimage:self.myimage]; self.myimageview.userinteractionenabled = yes; cgrect cellrectangle; self.myimageview.contentmode = uiviewcontentmodescaleaspectfit; cellrectangle = cgrectmake(0, 0, self.myimage.size.width/5, self.myimage.size.height/5);
and uilongpressgesturerecognizer
code:
self.lpgr = [[uilongpressgesturerecognizer alloc] initwithtarget:self action:@selector(handlelongpressgestures:)]; self.lpgr.minimumpressduration = 2.0; //seconds self.lpgr.accessibilityframe = cellrectangle; [self.customcam addgesturerecognizer:self.lpgr];
where customcam
view on camera shown ar.
- (void)handlelongpressgestures:(uilongpressgesturerecognizer *)sender { if ([sender isequal:self.lpgr]) { if (sender.state == uigesturerecognizerstatebegan) { cgpoint p = [self.lpgr locationinview:self.myimageview]; nslog(@"taplong run on points %@",nsstringfromcgpoint(p)); } } }
the problem code applies uilongpressgesturerecognizer
on of customcam
view.
how bound it'll remain within myimageview
. i've tried doing this:
[self.myimageview addgesturerecognizer:self.lpgr];
but didn't work , i've added self.myimageview.userinteractionenabled = yes;
where have added [self.customcam addgesturerecognizer:self.myimageview];
first add image view in custom view add self.lpgr in myimageview. replace line [self.customcam addgesturerecognizer:self.lpgr];
this
[myimageview addgesturerecognizer:self.lpgr]
; , try
Comments
Post a Comment