Guest User

Untitled

a guest
Jan 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. -(UITableViewCell*)tableView:(UITableView *)ourTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  2. {
  3. NSString* className = [self classNameForIndexPath:indexPath];
  4.  
  5. // Have to dequeue the cell before getting the row, because that's how we reuse rows as well.
  6. UITableViewCell *cell = [ourTableView dequeueReusableCellWithIdentifier:className];
  7. TiUITableViewRowProxy* row = [usingRows objectForKey:indexPath];
  8. if (row == nil) {
  9. row = [[self rowForClassName:className] retain];
  10. [row setRow:[indexPath row]];
  11. [self dequeueRow:row forIndex:indexPath];
  12. }
  13.  
  14. NSDictionary * callbackArg = [NSDictionary dictionaryWithObjectsAndKeys:row,@"row",NUMINT([indexPath row]),@"index",nil];
  15. [[self proxy] fireCallback:@"rowLoader" withArg:callbackArg withSource:nil];
  16. TiThreadProcessPendingMainThreadBlocks(0.05,NO,^(BOOL * result){
  17. //TODO: If there is some way to detect that the callback has completed, now would
  18. //be a great time to do that.
  19. // if([self rowCachedForIndexPath:indexPath]) {*result = NO;}
  20. });
  21.  
  22. [row triggerAttach];
  23.  
  24. // TIME FOR C&P LOGIC FROM TABLEVIEW....
  25.  
  26. if (cell == nil)
  27. {
  28. cell = [[[TiLazytableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:row.tableClass row:row] autorelease];
  29. CGSize cellSize = [(TiUITableViewCell*)cell computeCellSize];
  30. [cell setBounds:CGRectMake(0, 0, cellSize.width,cellSize.height)];
  31. [[cell contentView] setBounds:[cell bounds]];
  32. }
  33. else
  34. {
  35. // TODO: Right now, reproxying, redrawing, reloading, etc. is SLOWER than simply drawing in the new cell contents!
  36. // So what we're going to do with this cell is clear its contents out, then redraw it as if it were a new cell.
  37. // Keeps the cell pool small and reusable.
  38. [TiUITableViewRowProxy clearTableRowCell:cell];
  39.  
  40. // Have to reset the proxy on the cell, and the row's callback cell, as it may have been cleared in reuse operations (or reassigned)
  41. [(TiUITableViewCell*)cell setProxy:row];
  42. [row setCallbackCell:(TiUITableViewCell*)cell];
  43. }
  44. [row initializeTableViewCell:cell];
  45. [cell setIndex:indexPath];
  46.  
  47. return cell;
  48. }
Add Comment
Please, Sign In to add comment