iPhone:如何在两个表视图中使用UITableViewCell

Jim*_*Jim 5 iphone uitableview

我有2个继承UITableViewControllers的类.这两个表视图应该使用相同的自定义UITableViewCell.那么如何在两个不同的类中使用Nib文件中的自定义UITableViewCell?xib的所有者只能是1级.

@interface Class1 : UITableViewController<UITableViewDataSource,
    UITableViewDelegate> {
UITableViewCell *myCustomTableRow;
}

@property (nonatomic, retain) IBOutlet UITableViewCell *myCustomTableRow;





@interface Class2 : UITableViewController<UITableViewDataSource,
    UITableViewDelegate> {
UITableViewCell *myCustomTableRow;
}

@property (nonatomic, retain) IBOutlet UITableViewCell *myCustomTableRow;
Run Code Online (Sandbox Code Playgroud)

rak*_*hNS 3

创建一个UITableViewController子类 say CommonTableView。使其成为 nib 文件的所有者。然后从Class继承你要实现的两个类CommonTableView。这会工作得很好。