問題描述
我在 Today 小部件中使用了 UIView
子類.該視圖使用滑動手勢.但是,這些手勢要么上下滾動整個通知中心,要么讓通知中心從 Today 切換到 Notifications.
有什么方法可以防止觸摸事件冒泡到通知中心滾動視圖?在子類中使用[self setExclusiveTouch:YES];
并沒有解決,很遺憾.
有什么方法可以防止觸摸事件冒泡到通知中心滾動視圖?使用 [self setExclusiveTouch:YES];不幸的是子類中沒有解決.
沒有.由于您的 Today 小部件在內(nèi)部呈現(xiàn)遠(yuǎn)程視圖托管,[self setExclusiveTouch:YES]
并不能完全滿足您的需求.
iOS 8.0 中的粗略架構(gòu)是:
<上一頁>[用戶觸摸創(chuàng)建一個UITouch]|v通知中心(UIScrollView)|vUIRemoteView 容器(呈現(xiàn)你的 UIView)[跨越流程邊界]|v你的 Today 小部件的 UIView當(dāng)觸摸越過進(jìn)程邊界時,就可以認(rèn)為它基本上是被克隆的.您的視圖的專有觸摸需求僅與您的小部件的進(jìn)程空間/窗口相關(guān),并且不會向外傳播到遠(yuǎn)程托管您的通知中心.
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.
這篇關(guān)于在 iOS 8 Today Extensions 中拖動手勢的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!