iOS 9 UITableView separators insets (significant left margin)

后端 未结 11 2143
故里飘歌
故里飘歌 2020-12-02 16:41

I have a problem with separators between UITableViewCells in UITableView on iOS 9. They have the significant left margin. I already ha

11条回答
  •  佛祖请我去吃肉
    2020-12-02 17:30

    For iOS 8 and 9

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        if ([UITableView instancesRespondToSelector:@selector(setLayoutMargins:)]) [[UITableViewCell appearance] setLayoutMargins:UIEdgeInsetsZero];
        if ([UITableView instancesRespondToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) [[UITableViewCell appearance] setPreservesSuperviewLayoutMargins:NO];
    }
    

    and

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    

提交回复
热议问题