开发者

Disable selection effect when selecting UITableViewCell

How can I disable the selection effect when s开发者_运维知识库electing a particular UITableViewCell?


in tableView:cellForRowAtIndexPath: method

use this

cell.selectionStyle = UITableViewCellSelectionStyleNone


Swift 3.0

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "CellIdentifier", for: indexPath) as! UITableViewCell
    cell.selectionStyle = .none
    return cell
  }

The job is done by setting:

cell.selectionStyle = .none


In Swift 4.5/5.0

cell.selectionStyle = UITableViewCell.SelectionStyle.none

Or,

cell.selectionStyle = .none


There a delegate method to setselectionstyle to none.Once this is set reloading the table gives the desired effect.


you can use:

cell.selectionStyle = UITableViewCellSelectionStyleNone;


you can use cell.selectionStyle = UITableViewCellSelectionStyleNone;

or

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

in cellForRowAtIndexPath dataSource method


Write this in didSelectRowAtIndexPath:index method,

cell.selectionStyle = UITableViewCellSelectionStyleNone

OR

[self.tblName deselectRowAtIndexPath:indexPath animated:NO];


Also you can use this one:

UITableViewCell.appearance().selectionStyle = .none

Consider this behavior for other tableviews in your app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜