你必须继承和 UITableViewCell
@interface OutlineCell : UITableViewCell
然后,在您的表的 ViewController 中
- (UITableViewCell*) tableView: (UITableView*) tableView cellForRowAtIndexPath: (NSIndexPath*) indexPath {
NSString* MyIdentifier = @"MyIdentifier";
OutlineCell* cell = (OutlineCell*) [tableView dequeueReusableCellWithIdentifier: MyIdentifier];
if (cell == nil) {
cell = [[OutlineCell alloc] init];
}
// Populate cell data
}
您可以通过 IB 定义界面,创建一个 Empty XIB 并拖动一个 UITableViewCell,并将您的自定义 OutlineCell 类作为文件所有者。然后添加按钮、标签等。
编辑:如果您想要一个单元格内的内部表格,请尝试使用相同的方法向您定义的 UITableViewCell 添加一个子视图,其中包含一个 UITableView 。