星空网 > 软件开发 > 操作系统

【原】tableView的常见BUG

1、TableView头视图不随视图移动,头视图出现错位

【原】tableView的常见BUGimages/loading.gif' data-original="cid:ba2729a587cfa202c30cf26b78232d24" width="288" data-en-img-selected="true" />

  错误原因:tableView的 UITableViewStyle 没有明确的声明

 

  解决方法:在tableView声明的时候明确为 UITableViewStyleGrouped

 

2、分组表视图顶部空白高度调整

【原】tableView的常见BUG

 实现方式:

  方式一(推荐使用):

    Swift:

func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {  if section == 0 {    return CGFloat.min  }  return tableView.sectionHeaderHeight}

    Obj-C:

 - (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{  if (section == 0)    return CGFLOAT_MIN;  return tableView.sectionHeaderHeight;}


  
  方式二:

     In the loadView

_tableView.sectionHeaderHeight = 0;

    Then 

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{  return 0;}

 



  方式三: 

- (void)viewWillAppear:(BOOL)animated{  CGRect frame = self.tableView.tableHeaderView.frame;  frame.size.height = 1;  UIView *headerView = [[UIView alloc] initWithFrame:frame];  [self.tableView setTableHeaderView:headerView];}

 




原标题:【原】tableView的常见BUG

关键词:ie

ie
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流