在 iOS 8 Today Extensions 中拖动手势

Dragging Gestures in iOS 8 Today Extensions(在 iOS 8 Today Extensions 中拖动手势)

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

问题描述

我在 Today 小部件中使用了 UIView 子类.该视图使用滑动手势.但是,这些手势要么上下滚动整个通知中心,要么让通知中心从 Today 切换到 Notifications.

有什么方法可以防止触摸事件冒泡到通知中心滚动视图?在子类中使用[self setExclusiveTouch:YES];并没有解决,很遗憾.

解决方案

有什么方法可以防止触摸事件冒泡到通知中心滚动视图?使用 [self setExclusiveTouch:YES];不幸的是子类中没有解决.

没有.由于您的 Today 小部件在内部呈现远程视图托管,[self setExclusiveTouch:YES] 并不能完全满足您的需求.

iOS 8.0 中的粗略架构是:

<上一页>[用户触摸创建一个UITouch]|v通知中心(UIScrollView)|vUIRemoteView 容器(呈现你的 UIView)[跨越流程边界]|v你的 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.

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.

解决方案

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.

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.

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 Today Extensions 中拖动手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 iOS 8 Today Extensions 中拖动手势

基础教程推荐