UITableView --allowsSelection

下面是官方的詳細解釋

A Boolean value that determines whether users can select a row.
**Declaration**
OBJECTIVE-C
@property(nonatomic) BOOL allowsSelection
**Discussion**
If the value of this property is YES (the default), users can select rows. If you set it to NO, they cannot select rows. Setting this property affects cell selection only when the table view is not in editing mode. If you want to restrict selection of cells in editing mode, use allowsSelectionDuringEditing.
**Availability**
Available in iOS 3.0 and later.
也就是說這是一個BOOL類型的變量,決定使用者是否可以選擇一行。
由于在某種情況下,我們需要對UITableView的cell做特殊的處理(比如說,在某種條件下,我們希望點擊cell的時候不需要做出任何的反應(yīng)。
這個時候,我們只需要將UITableView對象的allowsSelection屬性設(shè)置為NO即可,在需要點擊cell之后做出反應(yīng),再將這個屬性設(shè)置為YES即可。
allowsSelection屬性只適應(yīng)于當(dāng) table view不是編輯模式的時候。
當(dāng)你需要在編輯模式下限制cell的選擇,那么你就要考慮使用allowsSelectionDuringEditing這個屬性。官方給出的詳細解釋如下

A Boolean value that determines whether users can select cells while the table view is in editing mode.
**Declaration**
OBJECTIVE-C
@property(nonatomic) BOOL allowsSelectionDuringEditing
**Discussion**
If the value of this property is YES, users can select rows during editing. The default value is NO. If you want to restrict selection of cells regardless of mode, use allowsSelection.
**Availability**
Available in iOS 2.0 and later.

這里我就不再做詳細的說明。(第一次寫簡書,寫的不對的地方,請多多指教。)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容