iPhone UITableView Selected State
While playing around the other day in Xcode, I wanted to change a row of a table view to a different colour other than blue when selected. Now after having a look high and low for a solution, I figured I would throw a few things at it and see what I could come up with. I managed to sort it all out by using the below code:
– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
With ‘cell’ being the UITableView row, you can use the above to change the selected state to gray. Other options available are:
UITableViewCellSelectionStyleGray (demonstrated above)
UITableViewCellSelectionStyleBlue (default)
UITableViewCellSelectionStyleNone
More information can be found here.
Yours in iPhone Development,
Lee