gpt4 book ai didi

iphone - objective-c : How to highlight the first cell in table view when view loads?

转载 作者:行者123 更新时间:2023-12-01 17:35:04 25 4
gpt4 key购买 nike

我试图默认我的表格 View 中的顶部单元格在 subview 出现时突出显示。

我试图这样做:

switch(indexPath.row) { // assuming there is only one section
case 0:
cell.textLabel.text = @"First Cell:";
cell.highlighted = YES
break;

但这不起作用,因为我在第一个单元格上得到了黑色覆盖。

编辑(添加截图)

enter image description here

对此的任何建议将不胜感激!

谢谢

最佳答案

我有同样的问题。您需要将代码移动到 willDisplayCell,而不是 cellForRowAtIndexPath。

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

if(indexPath.row == 0) {

[cell setSelected:YES animated:NO];
}
}

关于iphone - objective-c : How to highlight the first cell in table view when view loads?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6053546/

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