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

筅森魡賤 提交于 2019-12-09 05:20:17

问题


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.


回答1:


Try it (you can choose appearanceWhenContainedInInstancesOfClasses instead).

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    ...

    [[UITableViewCell appearance] setBackgroundColor:[UIColor clearColor]];

    return YES;
}



回答2:


I tried everything that's possible and only thing that work was

adding

UITableViewCell.appearance().backgroundColor = UIColor.clear

in didFinishLaunchingWithOptions




回答3:


Just a suggestion: Make sure all elements have a transparent background color or the light blue you are using. Apparently there is one that still has a white background color, could be the cell content view (if you have one) or the cell background.



来源:https://stackoverflow.com/questions/46477291/ios-11-xcode-9-uitableviewcell-white-background-flickers-on-delete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!