Created
May 7, 2015 18:00
-
-
Save simondec/000e06969bb9e3597e92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface TestViewController : UITableViewController | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "TestViewController.h" | |
@interface TestViewController () | |
@property (nonatomic) NSMutableDictionary *dict; | |
@end | |
@implementation TestViewController | |
- (void)viewDidLoad { | |
self.dict = [NSMutableDictionary new]; | |
[super viewDidLoad]; | |
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"]; | |
} | |
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | |
{ | |
return 20; | |
} | |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath]; | |
if (self.dict[@(indexPath.row)]) { | |
cell.backgroundColor = [UIColor redColor]; | |
} | |
return cell; | |
} | |
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
[tableView deselectRowAtIndexPath:indexPath animated:NO]; | |
self.dict[@(indexPath.row)] = @"YES"; | |
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment