Note that there are some explanatory texts on larger screens.

plurals
  1. POCell is not being rendered in UITableView after insert/delete cells
    primarykey
    data
    text
    <p>I have a tableview which can work in 2 modes: read-only and read-write. In read-only mode table contains only 4 cells, in read-write mode - 8 cells. To transit between these 2 modes I have button with implemented action:</p> <pre><code>... NSArray* cellIndexesInCurrentMode = [self cellIndexesInMode:Mode1]; NSArray* cellIndexInNewMode = [self cellIndexesInMode:Mode2]; [self.tableView beginUpdates]; [self.tableView insertRowsAtIndexPaths: cellIndexInNewMode withRowAnimation:UITableViewRowAnimationFade]; [self.tableView deleteRowsAtIndexPaths:cellIndexesInCurrentMode withRowAnimation:UITableViewRowAnimationFade]; [self.tableView endUpdates]; </code></pre> <p>Everything works fine, until I scroll table down in read-write (8-cells), so it bounced up. After that, tapping on the button to transit to mode2 leads to situation when one of the cells are not renderred:</p> <pre><code> before transition: </code></pre> <p><img src="https://i.stack.imgur.com/LzRWF.png" alt="before transition:"></p> <pre><code> after transition: </code></pre> <p><img src="https://i.stack.imgur.com/VYmfk.png" alt="after transition:"></p> <p>My investigation showed that for some reason this cell has alpha = 0 after the last layoutSubviews call on UITableView.</p> <p>I am stuck, I have no idea what is going on, so any help will be much appreciated.</p> <p><strong>UPDATE:</strong> Here is my cellForRowAtIndexPath method: - (UITableViewCell*) tableView :(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)cellForRowAtIndexPath { IDataSourceElement item = [[self collection] getDataSourceElementAtIndex:cellForRowAtIndexPath.row];</p> <pre><code>MyTableCell* cell = nil; if ([item conformsToProtocol:@protocol(MyTableCellBuilder)]) { cell = [(MyTableCellBuilder)item tableView:tableView buildCellForIndexPath:cellForRowAtIndexPath]; } if (cell == nil) { Class cellClass = [self getCellClassForElement: item]; NSString* reuseId = [cellClass description]; cell = [tableView dequeueReusableCellWithIdentifier:reuseId]; if (!cell) { cell = [[[cellClass alloc] initWithReuseIdentifier :reuseId] autorelease]; } } [self fillCell:cell forTableView:tableView forIndexPath:cellForRowAtIndexPath]; return cell; </code></pre> <p>}</p> <p>And MyTableCellBuilder buildCellForIndexPath: method implementation</p> <pre><code>- (MyTableCell*) tableView :(UITableView*)tableView buildCellForIndexPath:(NSIndexPath*)buildCellForIndexPath { MyTableCell* cell = myTableCell; if ([cell isKindOfClass:[TextPropertyCell class]] == NO) { cell = (MyTableCell*)[tableView dequeueReusableCellWithIdentifier :[self cellReuseIdentifier]]; if ([cell isKindOfClass:[MyTableCell class]] == NO) { cell = [[[MyTableCell alloc] initWithReuseIdentifier :[self cellReuseIdentifier]] autorelease]; } [self prepareCell:cell]; } //cell setup ... ... return cell; } </code></pre> <p>My idea was that the problem with caching instance of UITableViewCell, I know that it is not best way to do, but anyway I had it. I tried to remove caching, so all I did I set myTableCell to nil, so it is never returned from this method. And... it helped! I don't know why and would really like to know the answer?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload