customCell 图像在 didSelectRowAtIndexPath 上没有响应(但在其他方面有效)
我有一个很好的 UITableView 自定义单元格,一切正常。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = nil;
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CustomCell *) currentObject;
break;
}
}
}
// LOOK HERE: cellArrowPointingRight is an UIImage view of which I like to turn on later
[cell.cellArrowPointingRight setHidden:YES];
// The above line works as it hides all cellArrowPointingRight(s)
return cell;
}
在自定义视图(在IB中制作)中我也有cellArrowPointingRight(它连接到M中的H和@synthesize cellArrowPointingRight,
问题是我在选择单元格时无法运行它
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// cell.contentView.backgroundColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.5];
cell.textLabel.text = @"Clicked";
// PROBLEM HERE: (cellArrowPointingRight is not legal)
[cell.cellArrowPointingRight setHidden:NO];
}
我该如何解决这个问题?
I have my a nice customCell for UITableView , all works well.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = nil;
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CustomCell *) currentObject;
break;
}
}
}
// LOOK HERE: cellArrowPointingRight is an UIImage view of which I like to turn on later
[cell.cellArrowPointingRight setHidden:YES];
// The above line works as it hides all cellArrowPointingRight(s)
return cell;
}
in the custom view (made in IB) I also have cellArrowPointingRight (it is connected to the H and @synthesize cellArrowPointingRight in the M
problem is that I can not run it on when selecting a cell
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// cell.contentView.backgroundColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.5];
cell.textLabel.text = @"Clicked";
// PROBLEM HERE: (cellArrowPointingRight is not legal)
[cell.cellArrowPointingRight setHidden:NO];
}
How do I solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您使用时:
默认单元格通常不应该有一个名为 cellArrowPointingRight 的字段,因此普通的 UITableViewCell 不会对此做出响应。
您需要做的是将单元格获取为:
假设您的 CustomCell 是 UITableViewCell 的超类。
As you are using :
That default cell should not normally have a field called cellArrowPointingRight therefore a normal
UITableViewCell
would not respond to that.What you need to do is to get the cell as :
Assuming that your CustomCell is a superclass of UITableViewCell.