我有一个自定义单元格,在这个自定义单元格中我有一个按钮和一个标签:
#import <UIKit/UIKit.h>
@interface ListCell : UITableViewCell{
}
@property (nonatomic, retain) IBOutlet UIButton* buttonContent;
@property (nonatomic, retain) IBOutlet UILabel* detailContent;
@end
当我处理按钮的点击事件时:
- (IBAction)expandListCell:(id)sender{
UIButton *button = (UIButton *)sender;
ListCell *cell = (ListCell *)button.superview;
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
cell.detailContent.text = @"FALSE"; // It throw an exception
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"listCell";
ListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.buttonContent.tag = indexPath.row;
return cell;
}
当我尝试从我的自定义单元格(ListCell)访问任何项目时,它会引发异常:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCellContentView detailContent]: unrecognized selector sent to instance 0x8887ca0'
我认为我获得自定义单元格的方式是错误的。有谁知道如何正确获取它?
预先感谢