gpt4 book ai didi

ios - 如何更改 UITableView 中选定单元格的颜色?

转载 作者:行者123 更新时间:2023-12-01 18:12:41 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Changing background color of selected cell?

(30 个回答)


7年前关闭。




我正在制作一个应用程序,其中我在 UITableView 中显示我的数据.我被困住了。我想更改所选单元格的颜色。这该怎么做?

以下是我在 -didSelectRowAtIndexPath 中的代码

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"the messageid==%@",[[self.inboxmessagesarray objectAtIndex:indexPath.row ] objectForKey:@"messageId"]);
manage.messageid=[[self.inboxmessagesarray objectAtIndex:indexPath.row ] objectForKey:@"messageId"]; // here i pass the value to singleton class
[self performSegueWithIdentifier:@"segueIdentifier" sender:tableView];
}

最佳答案

如下所述更新您的代码:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"the messageid==%@",[[self.inboxmessagesarray objectAtIndex:indexPath.row ] objectForKey:@"messageId"]);

manage.messageid = [[self.inboxmessagesarray objectAtIndex:indexPath.row ] objectForKey:@"messageId"]; // here i pass the value to singleton class

[self performSegueWithIdentifier:@"segueIdentifier" sender:tableView];

// Add this line to set selected default gray style
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}

使用 selectionStyle 属性使单元格突出显示。更多详情请引用 UITableViewCellSelectionStyle

关于ios - 如何更改 UITableView 中选定单元格的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27478130/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com