Iphone 表单元原型-插座不工作
我有一个定制类的细胞原型,我有插座 STRMEpisodeCell.hIphone 表单元原型-插座不工作,iphone,ios,uitableview,ios6,Iphone,Ios,Uitableview,Ios6,我有一个定制类的细胞原型,我有插座 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, nonat
#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
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]上设置断点时;在单元格中,它只是显示所有的插座都为零
我做错了什么吗?当使用在情节提要中设置的表视图单元格时,不应该注册该类,因为这样会使表视图无法获得在IB中设置的单元格。我认为只有在完全用代码设置单元格时,才需要注册一个类
如果在xib文件中创建单元格,并具有自定义类,则注册nib而不是类。使用在序列图像板中设置的表视图单元格时,不应注册类,因为这将阻止表视图获取您在IB中设置的单元格。我认为您只想在完全用代码设置单元格时注册一个类
如果在xib文件中创建单元格,并拥有自定义类,则注册nib而不是类。更多IB屏幕截图-nib的顶级类和文件所有者是什么?如果在故事板中设置此单元格,则无需注册类,我想当我这样做时,它实际上使它无法正常工作,因此请尝试对此进行评论。我不确定这是否会有所不同,但请使用dequeueReusableCellWithIdentifier:forIndexPath:而不仅仅是dequeueReusableCellWithIdentifier:.rdelmar:OMG谢谢,这是类注册,谢谢先生!只有到那时我才会把它设置成IB。如果你愿意,把它改写成答案,我以后会接受的。顺便说一句,我正在使用故事板。更多IB截图-你的nib的顶级类和文件所有者是什么?如果你在故事板中设置了这个单元,那么你不需要注册这个类,我想当我这样做的时候,它实际上使它无法正常工作,所以试着评论一下。我不确定这是否会有所不同,但请使用dequeueReusableCellWithIdentifier:forIndexPath:而不仅仅是dequeueReusableCellWithIdentifier:.rdelmar:OMG谢谢,这是类注册,谢谢先生!只有到那时我才会把它设置成IB。如果你愿意,把它改写成答案,我以后会接受的。顺便说一句,我正在使用故事板。
- (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;
}