objective c - iOS project:Why the long press gesture is so easy to be triggered? -
just title says, when update xcode8, in project, long press gesture easy triggered, when tap screen, call up! , keyboard have problem. when type word, xcode print infomation follow:
[uiwindow enddisablinginterfaceautorotationanimated:] called on <uiremotekeyboardwindow: 0x100ffb940; frame = (0 0; 414 736); opaque = no; autoresize = w+h; layer = <uiwindowlayer: 0x17042d700>> without matching -begindisablinginterfaceautorotation. ignoring. and in view, add tap gesture , longpress gesture, when tap(just touch), gesture triggered longpress, not tap gesture. problem have'not searched anywhere, come here ask help. (forgive me, terrible on english)
i post 2 pictures can know clearly.


this code:
uilongpressgesturerecognizer * lp = [[uilongpressgesturerecognizer alloc] initwithtarget:self action:@selector(lp:)]; lp.minimumpressduration = 1.0f; [_imageview addgesturerecognizer:lp]; - (void)lp:(uilongpressgesturerecognizer*)lp {     if (lp.state == uigesturerecognizerstatebegan) {         if (self.delegate && [self.delegate respondstoselector:@selector(longpressimage)]) {             [self.delegate longpressimage];         }     } } additionally,this problem happend on devices,not devices.one device happend,others happend sometime,when build project again ,it oko__o "…
you should check uigesturerecognizerstateended instead of uigesturerecognizerstatebegan. uigesturerecognizerstatebegan triggered when touches recognized start of gesture. gesture isn't necessary long press you're looking for. @ point when recognizer state changes uigesturerecognizerstateended long press performed expecting.
- (void)lp:(uilongpressgesturerecognizer*)lp {     if (lp.state == uigesturerecognizerstateended) {         if (self.delegate && [self.delegate respondstoselector:@selector(longpressimage)]) {             [self.delegate longpressimage];         }     } } 
Comments
Post a Comment