gpt4 book ai didi

iphone - UITableViewCell 并不总是可选择的?

转载 作者:太空狗 更新时间:2023-10-30 03:49:13 25 4
gpt4 key购买 nike

我正在尝试调试新应用程序的问题,但有些地方不对劲。在应用程序中,我通过将 2 个 UILabel 和 1 个 UIImageView 直接添加到 cell.contentView 来设置自定义 UITableViewCells

在我的应用程序中,某些表格 View 单元格不可选择(它们不响应点击事件)。屏幕上的第二个单元格始终无法选择,然后随机其他单元格也无法选择。

在我的调试工作中,我将所有内容都剥离了以下代码的基本要素:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ReviewCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = @"foo";
return cell;
}

即使这是通用的样板代码,看起来如下所示:

并非所有单元格都是可选的。

我错过了什么?

更新

如有兴趣,这里更新了我的行选择代码

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ReviewWebViewController *rvc = [[ReviewWebViewController alloc] initWithReview:[self.reviews objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:rvc animated:YES];
[rvc release], rvc=nil;
}

最佳答案

很多事情已经提到了,我不会重复。

但是请确保您添加到 UITableViewCell 的元素的 userInteractionEnabled 设置为 NO。尤其是在不使用 IB 时,切勿对默认值做出过多假设。

关于iphone - UITableViewCell 并不总是可选择的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4676239/

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