forked from bestswifter/MySampleCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKtTableViewController.m
More file actions
43 lines (36 loc) · 1.09 KB
/
KtTableViewController.m
File metadata and controls
43 lines (36 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// KtTableViewController.m
// KtTableView
//
// Created by bestswifter on 16/4/16.
// Copyright © 2016年 zxy. All rights reserved.
//
#import "KtTableViewController.h"
#import "KtTableViewDataSource.h"
@implementation KtTableViewController
- (instancetype)initWithStyle:(UITableViewStyle)style {
self = [super init];
if (self) {
[self createDataSource];
}
return self;
}
// 这个方法实际上要被子类重写,生成对应类型的 data source
- (void)createDataSource {
@throw [NSException exceptionWithName:@"Cann't use this method"
reason:@"You can only call this method in subclass"
userInfo:nil];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self createTableView];
}
- (void)createTableView {
if (!self.tableView) {
self.tableView = [[KtBaseTableView alloc] initWithFrame:self.view.bounds style:self.tableViewStyle];
self.tableView.ktDelegate = self;
self.tableView.ktDataSource = self.dataSource;
[self.view addSubview:self.tableView];
}
}
@end