【发布时间】:2015-09-30 21:50:42
【问题描述】:
我想将两行之间的所有内容移到 detailCell.m 中,这样 cellForRowAtIndexPath 中的唯一代码就是剩下的三行。最有效的方法是什么?谢谢你。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
DetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DetailCell" forIndexPath:indexPath];
Job *aJob = self.jobs[indexPath.row];
_______________
[cell.titleLabel setText:aJob.title];
[cell.companyLabel setText:aJob.company];
if (aJob.logo != (NSString *)[NSNull null]) {
[cell.logoImageView setImageWithURL:[NSURL URLWithString:aJob.logo] placeholderImage:[UIImage imageNamed:@"placeholder.jpg"]];
}
else {
[cell.logoImageView setImage:[UIImage imageNamed:@"placeholder.jpg"]];
}
_________________
return cell;
}
这里是 DetailCell.h。 DetailCell.m 当前为空。
@interface DetailCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *companyLabel;
@property (weak, nonatomic) IBOutlet UIImageView *logoImageView;
@end
【问题讨论】:
标签: ios objective-c data-objects