gpt4 book ai didi

iphone - 选择时 Xcode UITableView 行未突出显示

转载 作者:行者123 更新时间:2023-12-05 08:44:28 25 4
gpt4 key购买 nike

我的 iphone 应用程序上有一个工作 TableView ,我正在使用 navigationController 实现第二个 View 。

但是当我尝试在初始 View 中选择一个单元格时,它没有响应,即没有蓝色突出显示,没有选择。

任何人都可以建议我可能遗漏了什么,或者当用户点击时实际选择单元格的负责人是什么?

好的,谢谢你的建议 - 还是不行。这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];

[cell setSelectionStyle: UITableViewCellSelectionStyleBlue];

UIView *selectionView = [[[UIView alloc] init] autorelease];
selectionView.backgroundColor =[UIColor redColor];
cell.selectedBackgroundView = selectionView;
}

// format text

cell.textLabel.font = [UIFont fontWithName:@"Arial" size:12];
cell.textLabel.text = [tableArray objectAtIndex:indexPath.row];

return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

//NSUInteger row = indexPath.row;
//[DetailView selectRowAtIndexPath:indexPath animated:YES];

//UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath.row];
//[cell setSelectionStyle: UITableViewCellSelectionStyleBlue];


DetailView *detailView = [[DetailView alloc] initWithNibName:@"DetailView" bundle:nil];
[self.navigationController pushViewController:detailView animated:YES];
[DetailView release];

}

最佳答案

可能是您在 cellForRowatIndexPath::

中完成了这行代码
 cell.selectionStyle = UITableViewCellSelectionStyleNone;

如果是,则将其替换为以下之一:

 cell.selectionStyle = UITableViewCellSelectionStyleGray;

 cell.selectionStyle = UITableViewCellSelectionStyleBlue;

关于iphone - 选择时 Xcode UITableView 行未突出显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9975037/

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