iOS TableView常见问题

Q:表视图只需要部分单元格,怎样删除下方多余的空白单元格?

A:viewDidLoad中添加

  self.tableView.tableFooterView=[[UIView alloc] init];

Q: tableView的顶部被navigationBar遮挡

A:

self.tableView.tableHeaderView = navigationBar;

消除表格分割线

tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

自定义tableViewCell适配tableView的宽度,可以重写自定义cell的setFrame方法

  - (void)setFrame:(CGRect)frame {
    frame.origin.x += inset;
    frame.size.width -= 2 * inset;
    [super setFrame:frame];
  }
原文地址:https://www.cnblogs.com/liuliuliu/p/4398843.html