方法1:
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style controller:(id<UITableViewDataSource, UITableViewDelegate>)controller
{if (self = [super initWithFrame:frame style:style]) {
//指定代理类为传进来的 VC类
self.dataSource = controller;
self.delegate = controller;
//添加controller上面
UIViewController *vc = (UIViewController *)controller;
[vc.view addSubview:self];
}
return self;
}