开发者

Use default blue background when UITableViewCell is selected

开发者 https://www.devze.com 2023-03-11 17:04 出处:网络
For a better user experience, I would like my UITableViewCell to have the default blue styling when a user taps it. Currently, there is no styling at all. Shouldn\'t the following this be all I need?

For a better user experience, I would like my UITableViewCell to have the default blue styling when a user taps it. Currently, there is no styling at all. Shouldn't the following this be all I need?

- (void)tableView:(UITableView *)tableView 
    didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{   
    [tableView selectRowAtIndexPath:indexPath 
        animated:NO scrollPosition:UITableViewScrollPositionNone];
    // [The rest of my code here开发者_如何学Python that loads up the detail view]
}

- (UITableViewCell *)tableView:(UITableView *)tableView 
    cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // [bunch of code]
    UITableViewCell *cell = [[[UITableViewCell alloc]
        initWithStyle:UITableViewCellStyleSubtitle
        reuseIdentifier:PlaceholderCellIdentifier] autorelease];
    // [bunch of code that sets the text of the cell];
    return cell;
}


Go to cellForRowAtIndexPath and use

cell.selectionStyle= UITableViewCellSelectionStyleBlue;
0

精彩评论

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