絵コンテを使っています。セルの新しいクラスを作成します。ストーリーボードで、再利用識別子「userFullCell」を記述します。私のセルクラス.h
#import <UIKit/UIKit.h>
@interface UsefullLinksCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *image;
@property (weak, nonatomic) IBOutlet UILabel *shortTitle;
@end
.mデフォルト
#import "UsefullLinksCell.h"
@implementation UsefullLinksCell
- (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
}
ストーリーボードでセルのUILabelとUIImageViewに接続されたプロパティ画像とshortTitle
次に、UITableViewを使用するクラスで、「UseFullLinksCell.h」をインポートし、viewDidLoadで次のように記述します。
[self.tableView registerClass:[UsefullLinksCell class] forCellReuseIdentifier:@"userFullCell"];
tableViewは私のアウトレットです:
@property (weak, nonatomic) IBOutlet UITableView *tableView;
次に、セルを作成しようとします。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"userFullCell";
UsefullLinksCell *cell = (UsefullLinksCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSDictionary *info = resourceArray[indexPath.row];
if(info){
cell.image.image = info[@"logo"];
cell.shortTitle.text = info[@"title"];
}
return cell;
}
したがって、セルは初期化されますが、画像とテキストは割り当てられず、メソッドの終了後にセルに対して0x0000000を返します。このメソッドで標準セルコード用に作成する場合、つまりUITableViewCell * cellを使用すると、すべて問題ありません。どこで間違えることができますか?PS申し訳ありませんが、ストーリーボードからスクリーンショットを提供することはできません。自分のコンピューターではなく、必要に応じて画像を後で提供するためです。