iOS 之 ExclusiveTouch

作者: Counting_S | 来源:发表于2016-12-29 11:32 被阅读1007次

    今天偶尔看到了一个之前没注意过的UIView的属性exclusiveTouch,在这里记录一下。

    文档中对这个属性的解释:

    A Boolean value that indicates whether the receiver handles touch events exclusively.
    Setting this property to YES causes the receiver to block the delivery of touch events to other views in the same window. The default value of this property is NO.

    这个属性主要是解决多个控件同时响应事件的问题,将exclusiveTouch设置为YES的话可以阻止同一个window中其他控件与他响应,默认为NO
    举个例子:页面中有按钮ButtonA 和 ButtonB,点击ButtonA会push该页面,点击ButtonB则会pop该页面,如果同时点击这个按钮的话页面就会连续出现pop和push的效果。如果设置了exclusiveTouchYES的话则可以避免发生这种事情。


    可以使用 appearance 在APPDelegate中对UIView进行统一的设置。

    [[UIView appearance] setExclusiveTouch:YES];
    

    相关文章

      网友评论

        本文标题:iOS 之 ExclusiveTouch

        本文链接:https://www.haomeiwen.com/subject/jyguvttx.html