Last active
June 12, 2016 00:28
-
-
Save talkol/c3d2a97a9edfd037ad1b520d0719649e to your computer and use it in GitHub Desktop.
This file contains 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
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex { | |
// will not add them as subviews yet because we don't need to draw them | |
// [super insertSubview:subview atIndex:atIndex]; | |
[_unusedCells addObject:subview]; | |
} | |
- (UIView*) getUnusedCell { | |
UIView* res = [_unusedCells lastObject]; | |
[_unusedCells removeLastObject]; | |
if (res != nil) { | |
res.tag = [_unusedCells count]; | |
} | |
return res; | |
} | |
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
static NSString *cellIdentifier = @"CustomCell"; | |
TableViewCell *cell = (TableViewCell *)[theTableView dequeueReusableCellWithIdentifier:cellIdentifier]; | |
if (cell == nil) { | |
cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; | |
cell.cellView = [self getUnusedCell]; | |
NSLog(@"Allocated childIndex %d for row %d", (int)cell.cellView.tag, (int)indexPath.row); | |
} else { | |
NSLog(@"Recycled childIndex %d for row %d", (int)cell.cellView.tag, (int)indexPath.row); | |
} | |
// there's another interesting piece still missing here.. | |
return cell; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment