小编tur*_*ess的帖子

iOS UITableView 单元格缩进

我正在以编程方式设置 UITableView。我希望单元格的内容跨越整个屏幕宽度。我已经成功地将单元格设置为跨越屏幕的宽度,但内容和分隔符仍然明显插入(下面的 iPad 屏幕截图)。

这是我的视图控制器实现中的 tableview 布局设置:

- (void) viewDidLoad {
    [super viewDidLoad];

    // table layout
    self.tableView.rowHeight = 192;
    UILayoutGuide *margins = [self.view layoutMarginsGuide];
    [self.tableView.leadingAnchor constraintEqualToAnchor:margins.leadingAnchor] ;
    [self.tableView.trailingAnchor constraintEqualToAnchor:margins.trailingAnchor];
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);

    CGRect tableRect = self.view.frame;
    self.tableView.frame = tableRect;

    // table colors
    self.tableView.backgroundColor = [UIColor grayColor];
    self.tableView.separatorColor = [UIColor grayColor];
    UIView *backView = [[UIView alloc] init];
    [backView setBackgroundColor:[UIColor grayColor]];
    [self.tableView setBackgroundView:backView];
}
Run Code Online (Sandbox Code Playgroud)

然后我设置单元格的内容:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell* cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
    cell.backgroundColor …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios contentful

6
推荐指数
1
解决办法
2842
查看次数

标签 统计

contentful ×1

ios ×1

objective-c ×1

uitableview ×1