[英]custom tableViewCell labels not showing
I'm trying to implement a custom view cell on UITableViewController. 我正在尝试在UITableViewController上实现自定义视图单元。
@interface PPCustomCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *tableViewTitle;
@property (weak, nonatomic) IBOutlet UILabel *tableViewSubtitle;
@end
PPCustomCell *cell = (PPCustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell.accessoryView == nil) {
UIImage *buttonUpImage = [UIImage imageNamed:@"button4.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage:buttonUpImage
forState:UIControlStateNormal];
[button setTitle:@"Unpaid" forState:UIControlStateNormal];
[button sizeToFit];
[button addTarget:self
action:@selector(tappedButton:)
forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = button;
}
cell.accessoryView.tag = indexPath.row;
cell.tableViewTitle.text = [[remindersArray objectAtIndex:indexPath.row]reminderName];
cell.tableViewSubtitle.text =[[remindersArray objectAtIndex:indexPath.row]reminderDueDate];
but getting this error 'NSInvalidArgumentException', reason: '-[UITableViewCell tableViewTitle]: unrecognized selector sent to instance 但收到此错误“ NSInvalidArgumentException”,原因:“-[UITableViewCell tableViewTitle]:无法识别的选择器已发送到实例
Please help. 请帮忙。
UPDATE - I was using this, removed this line it worked. 更新-我正在使用它,删除了这行有效。 [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellIdentifier]; [self.tableView registerClass:[UITableViewCell类] forCellReuseIdentifier:CellIdentifier];
Thanks everyone. 感谢大家。
You're not allocating any cells! 您没有分配任何单元!
Before your if (cell.accessoryView == nil)
call, you should include the following: 在进行if (cell.accessoryView == nil)
调用之前,应包括以下内容:
if (cell == nil) {
cell = [[PPCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:etc...];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.