iphone – 为什么UIView的exclusiveTouch属性没有阻塞?

iphone – 为什么UIView的exclusiveTouch属性没有阻塞?,第1张

概述我正在启动一个带有textField的简单UIView – 让我们称之为orderSetNameView – 按下按钮.我希望将此视图设为模态,但不使用 [UIViewController presentModalViewContoller:animated:]. 看来我可以简单地设置textInputView.exclusiveTouch = YES来实现这一点. 关于exclusiveTouc 我正在启动一个带有textFIEld的简单UIVIEw – 让我们称之为orderSetnameVIEw – 按下按钮.我希望将此视图设为模态,但不使用

[UIVIEwController presentModalVIEwContoller:animated:].

看来我可以简单地设置textinputVIEw.exclusivetouch = YES来实现这一点.

关于exclusivetouch的Apple文档说:

A Boolean value indicating whether the receiver handles touch events
exclusively. If YES,the receiver blocks other vIEws in the same
window from receiving touch events; otherwise,it does not. The
default value is NO.

我假设“相同的窗口”意味着相同的UIWindow,其中我只有一个.

问题是,当我实例化我的orderSetnameVIEw,将其添加为子视图,并设置exclusivetouch = YES时,触摸事件发生在我的应用程序的所有其他视图中,即其他视图中的触摸事件未按预期阻止.

// ....    [self.vIEw addSubvIEw:self.orderSetnameVIEw];    [self.orderSetnameVIEw openWithAnimationForAnimationStyle:kMK_AnimationStyleScaleFromCenter];}// Set as modalself.orderSetnameVIEw.exclusivetouch = YES;

不应该在所有其他视图中使用orderSetnameVIEw块触摸事件?我错过了什么?

解决方法 来自Apple开发者论坛:

exclusivetouch only prevents touches in other vIEws during the time in which there’s an active touch in the exclusive touch vIEw. That is,if you put a finger down in an exclusive touch vIEw touches won’t start in other vIEws until you lift the first finger. It does not prevent touches from starting in other vIEws if there are currently no touches in the exclusivetouch vIEw.

To truly make this vIEw the only thing on screen that can receive touches you’d need to either add another vIEw over top of everything else to catch the rest of the touches,or subclass a vIEw somewhere in your hIErarchy (or your UIWindow itself) and overrIDe hitTest:withEvent: to always return your text vIEw when it’s visible,or to return nil for touches not in your text vIEw.

总结

以上是内存溢出为你收集整理的iphone – 为什么UIView的exclusiveTouch属性没有阻塞?全部内容,希望文章能够帮你解决iphone – 为什么UIView的exclusiveTouch属性没有阻塞?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1084003.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存