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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Cancel current UIScrollView touch(取消当前 UIScrollView 触摸)
Scale image to fit screen on iPhone rotation(缩放图像以适应 iPhone 旋转时的屏幕)
Can UITableView scroll with UICollectionView inside it?(UITableView 可以在里面滚动 UICollectionView 吗?)
How to make a screenshot of all the content of a Scrollview?(如何截取 Scrollview 的所有内容?)
Swift iOS Set scrollView constraint below navigation bar programmatically(Swift iOS以编程方式在导航栏下方设置滚动视图约束)
UILabel sizeToFit method not working properly(UILabel sizeToFit 方法无法正常工作)