この質問に関してネット上で利用可能なリソースがたくさんあります。自分のセルに別のXIBファイル(UIViewContoller
)をロードする必要があります。私は自分のセルの外観をデザインして、そのデザインをセルにロードしたいと思っています。iphoneでtableviewのセルにxibファイルをロードするには
私はこのコードを書いていますが、例外が発生しています。
-[UIView setTableViewStyle:]: unrecognized selector sent to instance 0x6040de0
2011-07-11 14:42:27.461 TableViewTest[2776:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setTableViewStyle:]: unrecognized selector sent to instance 0x6040de0'
そして、ここではあなたがあなたのXIBファイルでUITableViewCell
なくUIView
を使用する必要があります
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
// Load the top-level objects from the custom cell XIB.
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"loadXibfile" owner:self options:nil];
// Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
cell = [topLevelObjects objectAtIndex:0];
}
return cell;
http://adeem.me/blog/2009/05/30/iphone-sdk-tutorial-part-6-creating-custom-uitableviewcell-using-interface-builder-uitableview/これは良いチュートリアルですこの質問のために。 –