This repository was archived by the owner on Jul 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYYTextExample.m
More file actions
65 lines (51 loc) · 1.85 KB
/
YYTextExample.m
File metadata and controls
65 lines (51 loc) · 1.85 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// YYTextExample.m
// YYKitSample
//
// Created by lichuanjun on 2018/9/19.
// Copyright © 2018年 lichuanjun. All rights reserved.
//
#import "YYTextExample.h"
@interface YYTextExample ()
@property (nonatomic, strong) NSMutableArray *titles;
@property (nonatomic, strong) NSMutableArray *classNames;
@end
@implementation YYTextExample
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"YYModel";
self.titles = @[].mutableCopy;
self.classNames = @[].mutableCopy;
[self addCell:@"YYLabel(多个单击文本)" class:@"YYLabelMultipleClickTextVC"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)addCell:(NSString *)title class:(NSString *)className {
[self.titles addObject:title];
[self.classNames addObject:className];
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _titles.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YYTextExample"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YYTextExample"];
}
cell.textLabel.text = _titles[indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *className = self.classNames[indexPath.row];
Class class = NSClassFromString(className);
if (class) {
UIViewController *ctrl = class.new;
ctrl.title = _titles[indexPath.row];
[self.navigationController pushViewController:ctrl animated:YES];
}
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end