本文介绍了在iOS 8今日扩展中拖动手势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Today小部件中使用了 UIView 子类。该视图使用滑动手势。但是,这些手势会上下滚动整个通知中心,或使通知中心从今天切换到通知

I'm using a UIView subclass in my Today widget. The view makes use of swiping gestures. However, these gestures either scroll the whole Notification Center up and down, or make the Notification Center switch from Today to Notifications.

有没有办法阻止触摸事件冒泡到Notification Center滚动视图?不幸的是,在子类中使用 [self setExclusiveTouch:YES]; 并没有解决它。

Is there any way to prevent the touch events to be bubbled up to the Notification Center scroll view? Using [self setExclusiveTouch:YES]; in the subclass did not solve it unfortunately.

推荐答案

否。由于远程视图托管您的Today小部件正在内部显示, [self setExclusiveTouch:YES] 并不能完全按照您的需要进行操作。

No. Because of the remote view hosting that your Today widget is being presented inside, [self setExclusiveTouch:YES] doesn't quite do what you want.

iOS 8.0中的粗略架构是:

The rough architecture in iOS 8.0 is:


[User touch creates a UITouch]
            |
            v
Notification Center (UIScrollView)
            |
            v
  UIRemoteView container
  (presents your UIView)
[crosses process boundary]
            |
            v
your Today widget's UIView

认为触摸在穿过过程边界时基本上被克隆。您的视图的独有触摸欲望仅与您的窗口小部件的进程空间/窗口相关,并且不会向外传播到远程托管您的通知中心。

Think of the touch as basically becoming cloned when it crosses the process boundary. Your view's exclusive touch desires are only relevant in your widget's process space/window, and don't propagate back outwards to the Notification Center which is hosting you remotely.

这篇关于在iOS 8今日扩展中拖动手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 06:59