您的位置:首页 > 移动开发 > IOS开发

自定义 tableView的初始化方法(作为自己日志)

2016-06-21 15:51 531 查看
方法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;

}

方法2调用方法1;

- (void)createTableView:(UITableViewStyle)style

{

    //数据源数组初始化

    _dataArray = [NSMutableArray array];

    //初始化

    _tableView = [[LQTableView alloc] initWithFrame:PCH_Bounds style:style controller:self];

}

执行方法2;

[self createTableView:UITableViewStylePlain];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息