Search code examples
uitableviewios11xcode9

iOS 11/Xcode 9: UITableViewCell white background flickers on delete


On iOS 11 device on deleting a UITableViewCell unexpected white background appears for some reason however all background colors are set to blue in storyboard (works fine on iOS10).

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        [self.bookmarks removeObjectAtIndex:indexPath.row];            
        [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }
}

Tried all types of UITableViewRowAnimation, doesn't solve the problem.

enter image description here


Solution

  • Try it (you can choose appearanceWhenContainedInInstancesOfClasses instead).

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        ...
    
        [[UITableViewCell appearance] setBackgroundColor:[UIColor clearColor]];
    
        return YES;
    }