반응형
v0.3.0
- Cell에 표시할 data를 cellInfo에서 분리
- cellInfo 설정 매소드 추가
- data 설정 매소드 추가
- 테스트 코드 변경
ChopeTableController
It is not subclass of UITableViewController.
Implemention of UITableViewDataSource, UITableViewDelegate.
@interface CPSimpleTableViewCell : UITableViewCell@property (nonatomic, weak) IBOutlet UILabel *titleLabel; @end @implementation CPSimpleTableViewCell - (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; [self.titleLabel setTextColor:[UIColor whiteColor]]; } + (CGFloat)heightForCell:(id)data indexPath:(NSIndexPath *)indexPath { return 40 + (indexPath.row+1); } - (void)updateData:(id)data indexPath:(NSIndexPath *)indexPath { [self.titleLabel setText:data]; [self setNormalBackgroundColor:indexPath]; } - (void)setNormalBackgroundColor:(NSIndexPath *)indexPath { if (indexPath.row % 2 == 0) { [self setBackgroundColor:[UIColor darkGrayColor]]; } else { [self setBackgroundColor:[UIColor purpleColor]]; } } - (void)selectedWithData:(id)data indexPath:(NSIndexPath *)indexPath { [self setBackgroundColor:[UIColor blueColor]]; } - (void)deselectedWithData:(id)data indexPath:(NSIndexPath *)indexPath { [self setNormalBackgroundColor:indexPath]; } - (void)highlightedWithData:(id)data indexPath:(NSIndexPath *)indexPath { [self setBackgroundColor:[UIColor redColor]]; } - (void)unhighlightedWithData:(id)data indexPath:(NSIndexPath *)indexPath { [self setNormalBackgroundColor:indexPath]; } @end
Create ChopeTableController
self.tableController = [[ChopeTableController alloc] init];
Set Table Information
ChopeTableInfo *tableViewInfo = [self.tableController addTableInfo:self.tableView paging:NO]; [tableViewInfo addCellClass:[CPSimpleTableViewCell class] cellIdentifier:CELL_IDENTIFIER_LABEL]; [tableViewInfo setDidLoadCellBlock:^(ChopeTableInfo *tableInfo, id <ChopeTableCellDelegate> cellDelegate, NSIndexPath *indexPath) { CPSimpleTableViewCell *cell = (CPSimpleTableViewCell *) cellDelegate; cell.button.tag = indexPath.row; [cell.button addTarget:self action:@selector(touchTestButton:) forControlEvents:UIControlEventTouchUpInside]; }]; [tableViewInfo setDidSelectRowBlock:^(ChopeTableInfo *cpTableInfo, NSIndexPath *indexPath) { NSLog(@"selected cell : %d", indexPath.row); }];
paging:YES is not tested.
Add Data
cell information is about one cell.
- Cell Class
- Cell identifier
for (NSUInteger i=1; i<=100; i++) { [tableViewInfo addData:[NSString stringWithFormat:@"item - %d", i] cellIdentifier:CELL_IDENTIFIER_LABEL]; }
Screenshot
Github
https://github.com/chope-yoonhg84/ChopeTableController
반응형
'Project > OpenSource' 카테고리의 다른 글
ChopeTableController (0) | 2014.06.06 |
---|---|
ChopeToastView v0.1.1 (0) | 2014.01.22 |
ChopeToastView로 cocoapods 처음 등록 (0) | 2014.01.17 |