@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *tableView
@property (nonatomic,strong) NSArray *dataSource
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad]
self.title = @"查看字体集"
[self.view addSubview:self.tableView]
}
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]
_tableView.delegate = self
_tableView.dataSource = self
_tableView.estimatedRowHeight = 0.0
_tableView.sectionHeaderHeight = 0.0
_tableView.sectionFooterHeight = 0.0
_tableView.estimatedSectionHeaderHeight = 0.0
_tableView.estimatedSectionFooterHeight = 0.0
[_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableView class])]
}
return _tableView
}
- (NSArray *)dataSource {
if (!_dataSource) {
_dataSource = [UIFont familyNames]
}
return _dataSource
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataSource.count
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableView class])]
cell.selectionStyle = UITableViewCellSelectionStyleNone
cell.textLabel.text = self.dataSource[indexPath.row]
return cell
}
@end