本文介绍了如何在UITableView中设置分隔符的全宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

所以我有一个UITableView,其中分隔符没有全宽。它在左侧前10像素结束。我在viewDidLoad中玩这个代码

So i have a UITableView where the separators don't have the full width. It ends like 10 pixels before the left side. I was playing around with this code in the viewDidLoad

self.tableView.layoutMargins = UIEdgeInsetsZero;

还可以在故事板中选择自定义或默认选择器。现在,所有填充的单元格都没有全宽度选择器,但是空单元格具有全宽度。

also in the storyboard when you can select custom or default selectors. Now all the cells that are populated don't have the full width selectors but the cells that are empty have full width.

我怎么能解决这个问题?

How on earth can i fix this?

感谢所有帮助

推荐答案

好的,我找到了答案。不知道为什么我以前没有遇到这个帖子,但当然在你发布一个问题之后,突然之后,正确的帖子就会出现在你面前。我从这篇文章得到了答案:

Ok i found the answer. Don't know why i didn't come across this post before but of course after you post a question then suddenly the right post just appears ahead of you. I got the answer from this post: iOS 8 UITableView separator inset 0 not working

只需在 TableViewController上添加此代码

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

    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

-(void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.tableView setSeparatorInset:UIEdgeInsetsZero];
    }

    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.tableView setLayoutMargins:UIEdgeInsetsZero];
    }
}

这篇关于如何在UITableView中设置分隔符的全宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 18:27