martes, 13 de septiembre de 2016

iOS: UITableView add selected background and select row

Cell:

- (void)awakeFromNib
{
    UIView *selectionColor = [[UIView alloc] init];
    selectionColor.backgroundColor = [ColorHelper sickGreen];
    self.selectedBackgroundView = selectionColor;
}

ViewController containing table view:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
   // Set selected or not selected here. Doing it anywhere else has no result because prior to showing
   // the cell iOS sets selected to NO after that this method is called
}

No hay comentarios:

Publicar un comentario