iphone开发: gesture recognition scrolling enabled simultaneously
<p><p>在我的应用中,我需要在我的背景滚动条上有一个向上滑动手势识别器。下面是我的代码</p>
<p>它在 viewDidLoad 中</p>
<pre><code>UISwipeGestureRecognizer *Swipe = [ initWithTarget:self action:@selector(SwipeRecognizer:)];
Swipe.direction = UISwipeGestureRecognizerDirectionUp;
;
</code></pre>
<p>它是 SwipeRecognizer:</p>
<pre><code>- (void) SwipeRecognizer:(UISwipeGestureRecognizer *)sender {
if (sender.direction | UISwipeGestureRecognizerDirectionUp){
NSLog(@" *** SWIPE UP ***");
}
}
</code></pre>
<p>问题是我无法同时启用滚动和捕捉手势。当我说未启用滚动时,我可以识别手势。但我需要同时滚动和手势识别。不可能吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>重写 <code>gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:</code> 方法以不阻塞 UIScrollViews Pan 识别器</p>
<p>它会起作用的……</p>
<p>不要忘记为自己添加代理以进行手势识别。正如@death7eater 的评论中提到的那样。</p></p>
<p style="font-size: 20px;">关于iphone开发: gesture recognition scrolling enabled simultaneously,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/12248509/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/12248509/
</a>
</p>
页:
[1]