-
Notifications
You must be signed in to change notification settings - Fork 69
/
DemoTableViewController.m
73 lines (56 loc) · 2.28 KB
/
DemoTableViewController.m
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
66
67
68
69
70
71
72
73
//
// DemoTableViewController.m
// PPDragDropBadgeView
//
// Created by StarNet on 5/21/15.
// Copyright (c) 2015 StarNet. All rights reserved.
//
#import "DemoTableViewController.h"
#import "PPDragDropBadgeView.h"
#import "TableViewCell.h"
@interface DemoTableViewController ()
@end
@implementation DemoTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView registerNib:[UINib nibWithNibName:@"TableViewCell" bundle:nil] forCellReuseIdentifier:@"reuseIdentifier"];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuseIdentifier1"];
self.tableData = @[
@{
@"section":@"addSubview",
@"identifier":@"reuseIdentifier",
},
@{
@"section":@"accessoryView",
@"identifier":@"reuseIdentifier1",
},
];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary* info = self.tableData[indexPath.row];
TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:info[@"identifier"] forIndexPath:indexPath];
cell.textLabel.text = info[@"section"];
if ([info[@"identifier"] isEqualToString:@"reuseIdentifier"]) {
cell.badgeView.text = [NSString stringWithFormat:@"%lu", indexPath.row+1];
} else {
//accessoryView
PPDragDropBadgeView* badge = [[PPDragDropBadgeView alloc] initWithFrame:CGRectMake(10, 10, 25, 25) dragdropCompletion:^{
NSLog(@"Drag Drop Done.");
}];
badge.text = [NSString stringWithFormat:@"%lu", indexPath.row+1];
//Please add to container first
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
[container addSubview:badge];
cell.accessoryView = container;
}
return cell;
}
@end