【发布时间】:2016-11-13 11:58:52
【问题描述】:
正如标题所说,当我更新Xcode8时,在我的项目中,长按手势很容易触发,即使我点击屏幕,它也会调用!而且键盘也有这个问题。当我输入一个单词时,Xcode 会打印如下信息:
[UIWindow endDisablingInterfaceAutorotationAnimated:] called on <UIRemoteKeyboardWindow: 0x100ffb940; frame = (0 0; 414 736); opaque = NO; autoresize = W+H; layer = <UIWindowLayer: 0x17042d700>> without matching -beginDisablingInterfaceAutorotation. Ignoring.
在一个视图中,我添加了一个点击手势和长按手势,当我点击(只是触摸)时,触发的手势是长按,而不是点击手势。这个问题我没有在任何地方搜索过,所以我来这里寻求您的帮助。 (原谅我,我的英语很糟糕)
我贴两张图让你看清楚。
这是我的代码:
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];
}
}
}
另外,这个问题发生在某些设备上,而不是所有设备上。一个设备总是发生,其他只是在某个时候发生,当我再次构建项目时,它只是 OKO__O "...
【问题讨论】:
-
请张贴代码。
-
抱歉,这个问题很难理解。
-
使用相关代码更新您的问题,展示您如何创建和设置长按手势以及如何处理其事件。
-
@shallowThought
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]; } } } -
@rmaddy
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]; } } }
标签: ios objective-c