UITableView Setting some cells as “unselectable”

后端 未结 16 1408

How can I set the UITableView\'s cell property to be unselectable? I don\'t want to see that blue selection box when the user taps on the cell.

相关标签:
16条回答
  • 2020-12-12 18:12

    use this:

    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    0 讨论(0)
  • 2020-12-12 18:12

    using IB is also an elegant way:

    enter image description here

    0 讨论(0)
  • 2020-12-12 18:13

    Swift 4:

    In the cell class:

    selectionStyle = .none
    
    0 讨论(0)
  • 2020-12-12 18:14

    There is another simple way to avoid the selection appearing as blue.

    Select a cell you don't want to appear as blue.

    Then select the attributes inspector (the shield icon next to the ruler icon on the properties view on the side).

    Then change the 'Selection' field from 'Blue' to 'None'.

    Note, presumably this is still selecting, it will just not appear as selected if all you want is to avoid the UI effect.

    0 讨论(0)
  • 2020-12-12 18:17

    Swift 5

    cell.isUserInteractionEnabled = false
    
    0 讨论(0)
  • 2020-12-12 18:18

    For iOS 6+ only.

    You can implement the method tableView:shouldHighlightRowAtIndexPath: in your delegate. Read more here : http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDelegate_Protocol/Reference/Reference.html

    0 讨论(0)
提交回复
热议问题