iOS 7.0 and Arc: Uitableview Never Deallocated After Rows Animation

Animation issue when deleting the last row of UITableView

UPDATE: This bug has been corrected in iOS 8. That final cell deletion now slides off to the left, the delete button slides up and away, and the background is clear (no more white area that abruptly disappears after the animations complete). The iOS 7 fix below is still needed when running below iOS 8.

iOS 7 Fix:
I was able to correct this problem by adding another section to the end of the table with a sufficiently tall section header view. This header view is styled to look like the blank area at the bottom of the table, so you can't see that it's there. When the last row of the table is deleted, this blank section header slides up and over it, hiding the delete button that's stuck there. This is a bit of a hack, but it looks like it's a table view bug.

Prevent views from popping from the top left during animations on iOS

The fix is to use dequeue and init cells with reuse identifiers. It still works when a cell appear the first time. The magic is to dequeue and init with the same non-null identifier.

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}

Basic advice on memory leaks in custom tableViewCells

You need to declare your custom delegate as weak

@property (nonatomic, weak) id<MyCustomDelegateProtocol> delegate;

Otherwise you get a strong reference cycle

controller -> table view -> cell -> controller

n.b. weak is specific to ARC, if you're not using ARC you need to use assign, and make sure to nil it out yourself when you're done being its delegate.

UITableView renders correctly in Simulator iOS 7.0, but not for iOS 6.1

The iOS simulator is usually reasonably accurate, so I'll assume that the same results will appear on an iPad running iOS 6.1. You might want to check how the cells appear on an iOS 6.1 storyboard, to make sure that you aren't setting them to black yourself by accident. If you go to your storyboard's file navigator view, there's an option to view it as iOS 7 or iOS 6.1 and earlier (outlined in red). Storyboard screen-capture

If this isn't the issue, I'd check any code you have that might be affecting the appearance of the cell. I know that the tintColor property, for example, has had its behaviour changed.



Related Topics



Leave a reply



Submit