xibでカスタムセルを作成しました。
NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
cell = [nibs objectAtIndex:0];
セル識別子を付けたいのですが。私は試した
cell.reuseIdentifier=@"";
ただし、その読み取り専用プロパティ。助けてください
Interface Builder でテーブルまたはセルを作成する場合は、オブジェクトの作成時にこのプロパティが設定されるため、Interface Builder で再利用識別子を設定する必要があります。Interface Builderではなく、プログラムでオブジェクト全体を作成する場合にのみ、プログラムで変更(より良い:設定)できます。
static NSString *CellIdentifier = @"YourCellName";
YourCellName *cell = (YourCellName *) [tablview dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"YourCellName" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (YourCellName *) currentObject;
break;
}
}
}