關於userInteractionEnabled的屬性的理解

來源:互聯網
上載者:User

標籤:style   class   color   get   strong   類   

userInteractionEnabled


A Boolean value that determines whether user events are ignored and removed from the event queue.

譯:一個布爾值,它決定了是否使用者觸發的事件被該視圖對象忽略和把該視圖對象從事件響應隊列中移除。


@property(nonatomic, getter=isUserInteractionEnabled) BOOL userInteractionEnabled

userInteractionEnabled的getter方法是isUserInteractionEnabled

我們可以通過isUserInteractionEnabled方法,得到userInteractionEnabled的布爾值。


Discussion
When set to NO, user events—such as touch and keyboard—intended for the view are ignored and removed from the event queue. When set to YES, events are delivered to the view normally. The default value of this property is YES.

譯:當視圖對象的userInteractionEnabled設定為NO的時候,使用者觸發的事件,如觸摸,鍵盤等,將會被該視圖忽略(其他視圖照常響應),並且該視圖對象也會從事件響應隊列中被移除。 當userInteractionEnabled設為YES時,則事件可以正常的傳遞給該視圖對象。 userInteractionEnabled的屬性預設值就是YES。

ps:響應者鏈是能夠響應事件的對象組成的鏈,事件在該鏈上傳遞,最終結果事件或被處理或被拋棄。所以一個對象在不在響應者鏈裡是其能否響應事件的首要前提條件!


During an animation, user interactions are temporarily disabled for all views involved in the animation, regardless of the value in this property. You can disable this behavior by specifying the UIViewAnimationOptionAllowUserInteraction option when configuring the animation.

譯:在播放動畫的時候,不論userInteractionEnabled的值是YES還是NO,使用者互動會被臨時設定為不支援互動的狀態。

如果在播放動畫的時候,你想讓對象依然保持可互動狀態,那麼你需要設定動畫的UIViewAnimationOptions的屬性值為UIViewAnimationOptionAllowUserInteraction。


Note: Some UIKit subclasses override this property and return a different default value. See the documentation for that class to determine if it returns a different value.

注意:一些UIKit的子類重寫了這個屬性,而導致返回不同的預設值。具體的你 需要看所選擇的類的文檔,看是否userInteractionEnabled被設定了不同的預設傳回值。


Declared In UIView.h

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.