我有带有自定义类的单元原型,其中有网点。
STRMEpisodeCell.h
#import <UIKit/UIKit.h>
#import "Show.h"
@interface STRMEpisodeCell : UITableViewCell
@property (weak, nonatomic) Show *show;
@property (weak, nonatomic) IBOutlet UILabel *showLabel;
@property (weak, nonatomic) IBOutlet UILabel *episodeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *posterView;
@end
STRMEpisodeCell.m
#import "STRMEpisodeCell.h"
@interface STRMEpisodeCell ()
@end
@implementation STRMEpisodeCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)setShow:(TVDbShow *)show
{
_show = show;
self.showLabel.text = show.title;
}
@end
STRMViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
self.episodeTable.dataSource = self;
[self.episodeTable registerClass:[STRMEpisodeCell class] forCellReuseIdentifier:@"episode"];
self.list = //loading data here;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
STRMEpisodeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"episode"];
cell.show = self.list[indexPath.row];
return cell;
}
当我在其中设置断点时cell.show = self.list[indexPath.item];
,cell
它只会显示所有出口都为零。
我做错什么了吗?