【发布时间】:2011-01-07 01:25:14
【问题描述】:
典型的 UITableView 使用模式是让主 UIViewController 成为目标数据源并委托它所持有的 UITableView。
是否有任何简单易学的教程可以帮助我弄清楚如何将与 UITableViewDelegate 和 UITableViewDataSource 方法相关的代码移动到一个单独的类中并将其挂接到我的 UIViewController 中?理想情况下,我希望委托和数据源都生活在同一个班级中。
现在,我正在通过 Interface Builder 创建 UITableView 并将其出口连接到我的控制器类。
典型代码:
@interface MyController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
IBOutlet UITableview *myTableview;
}
我想做更多这样的事情:
@interface MyController : UIViewController
{
IBOutlet UITableview *myTableview;
}
@end
@interface MyTableSourceDelegate : NSObject<UITableViewDelegate, UITableViewDataSource>
{
}
@implementation MyTableSourceDelegate
// implement all of the UITableViewDelegate and methods in this class
@end
【问题讨论】:
标签: iphone objective-c xcode