phizclip-ios-demo/FinDemo/ViewController.m

62 lines
1.9 KiB
Objective-C
Raw Normal View History

2023-05-31 11:00:11 +08:00
//
// ViewController.m
// FinDemo
//
// Created by 胡健辉 on 2023/5/29.
//
#import "ViewController.h"
@interface ViewController ()
@property (nonatomic, strong) NSMutableArray *dataArray;
@end
@implementation ViewController
static NSString *cellID = @"cellid";
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.dataArray = @[
@{@"title" : @"打开小程序", @"class" : @"FinStartAppletViewController"},
@{@"title" : @"日志管理", @"class" : @"FinManageViewController"},
@{@"title" : @"UI样式自定义", @"class" : @"FinCustomUIViewController"},
@{@"title" : @"api自定义", @"class" : @"FinCustomApiViewController"},
2023-06-01 15:26:07 +08:00
@{@"title" : @"代理方法", @"class" : @"FinDelegateViewController"},
2023-05-31 11:00:11 +08:00
].mutableCopy;
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellID];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 40;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *dic = self.dataArray[indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
cell.textLabel.text = dic[@"title"];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *dic = self.dataArray[indexPath.row];
UIViewController *vc = [NSClassFromString(dic[@"class"]) new];
vc.title = dic[@"title"];
if (vc) {
[self.navigationController pushViewController:vc animated:YES];
}
}
@end