【发布时间】:2014-05-26 14:06:09
【问题描述】:
我有 2 个自定义 UITableViewCell,并且都有属性。
尽管NSLog(@"%@", cell.class) 表明两者都被正确创建,但我无法在tableView:cellForRowAtIndexPath: 上设置我的属性。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
if (indexPath.row != [self.realties count]) {
cell = [tableView dequeueReusableCellWithIdentifier:RealtyCellIdentifier];
NSLog(@"%@", cell.class);
cell.realtyNameLabel.text = [[self.realties objectAtIndex:indexPath.row] adTitle];
cell.realtyPriceLabel.text = [NSString stringWithFormat:@"R$%ld", [[self.realties objectAtIndex:indexPath.row] price]];
}
if (indexPath.row == [self.realties count]) {
cell = [tableView dequeueReusableCellWithIdentifier:LoadMoreCellIdentifier];
NSLog(@"%@", cell.class);
}
return cell;
}
@import UIKit;
@interface IGBRealtyCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *realtyImageView;
@property (weak, nonatomic) IBOutlet UILabel *realtyNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *realtyPriceLabel;
@end
我错过了什么?
【问题讨论】:
-
cell被声明为UITableViewCell而不是IGBRealtyCell或YourSecondCustomCell。检查那里的情况:stackoverflow.com/questions/14303832/…
标签: objective-c ios7 uitableview