3400
post-template-default,single,single-post,postid-3400,single-format-standard,select-core-1.6,pitch-theme-ver-3.5,ajax_fade,page_not_loaded,smooth_scroll,grid_1300,vertical_menu_with_scroll,blog_installed,wpb-js-composer js-comp-ver-6.7.0,vc_responsive

iPhone UITableView Selected State

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

Belinda Vesey-Brown About the author
No Comments

Post a Comment