私に似たいくつかの質問を見ましたが、それらのどれも私の質問に答えませんでした。カスタムセルを持つ UITableview があります。
私のビュー階層:
UITableViewController を含むメインの UIViewController があります ** **UITableViewController にはカスタム UITableViewCell があります
UIViewController をロードするとセルは完全に表示されますが、上下にスクロールするとテーブルがクリアされ、そこには何も残りません...
メソッドは次のとおりです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCellReuseID";
EXCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[EXCustomCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
Post *post = [posts objectAtIndex:indexPath.row];
cell.imgBack.image=post.cover_img_url;
cell.imgProf.image=post.profile_img_url;
cell.lblValidUntil.text = post.exp_date;
cell.lblPost.text = post.sentence;
cell.lblLocation.text = post.location;
return cell;
}
そして、ここでviewdidload:
- (void)viewDidLoad
{
[self.tableView registerNib:[UINib nibWithNibName:@"EXCustomCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"CustomCellReuseID"];
}
そして最後にカスタムセルクラス
.m ファイル:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
.h ファイル:
@property (weak, nonatomic) IBOutlet UIImageView *imgBack;
@property (weak, nonatomic) IBOutlet UIImageView *imgProf;
@property (weak, nonatomic) IBOutlet UILabel *lblPost;
@property (weak, nonatomic) IBOutlet UILabel *lblValidUntil;
@property (weak, nonatomic) IBOutlet UILabel *lblLocation;
私はどこでも見ようとしましたが、問題を見つけることができませんでした。
どうもありがとう