UITableViewCell UITableViewCellSelectionStyleBlue
The style of selected cells.
typedef enum {
UITableViewCellSelectionStyleNone,
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray
} UITableViewCellSelectionStyle;
Constants
UITableViewCellSelectionStyleNone
The cell has no distinct style for when it is selected.
UITableViewCellSelectionStyleBlue
The cell when selected has a blue background. This is the default value.
UITableViewCellSelectionStyleGray
Then cell when selected has a gray background.
Discussion of [UITableViewCell UITableViewCellSelectionStyleBlue]
You use these constants to set the value of the selectionStyle property.
UITableViewCell UITableViewCellSelectionStyleBlue example.
You have to just put this code into cellForRowAtIndexPath
For disable the cell select:(While Click the cell)
cell.selectionStyle = UITableViewCellSelectionStyleNone;
For enable the cell:(While Click the cell)
cell.selectionStyle = UITableViewCellSelectionStyleBlue;(By Default)
cell.selectionStyle = UITableViewCellSelectionStyleGray;
Note that a cell with selectionStyle = UITableViewCellSelectionStyleNone will still cause the UI to call didSelectRowAtIndexPath when touched by the user. To avoid this, do as suggested below and set
For disable the cell select:(While Click the cell)
cell.selectionStyle = UITableViewCellSelectionStyleNone;
For enable the cell:(While Click the cell)
cell.selectionStyle = UITableViewCellSelectionStyleBlue;(By Default)
cell.selectionStyle = UITableViewCellSelectionStyleGray;
Note that a cell with selectionStyle = UITableViewCellSelectionStyleNone will still cause the UI to call didSelectRowAtIndexPath when touched by the user. To avoid this, do as suggested below and set
Example of [UITableViewCell UITableViewCellSelectionStyleBlue].
if(indexPath.row==x) // x is the numbered location of that particular cell appearing in table view
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.selectionStyle=UITableViewCellSelectionStyleGray; // UITableViewCellSelectionStyleBlue or UITableViewCellSelectionStyleNone
}
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.selectionStyle=UITableViewCellSelectionStyleGray; // UITableViewCellSelectionStyleBlue or UITableViewCellSelectionStyleNone
}
UITableViewCell UITableViewCellSelectionStyleBlue example.
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
self.selectionStyle = UITableViewCellSelectionStyleBlue;
[super setSelected:selected animated:animated];
}
self.selectionStyle = UITableViewCellSelectionStyleBlue;
[super setSelected:selected animated:animated];
}