TableView 去除最后一条分割线

项目中,采用系统默认的TableView, 一列,button 选中pickerView 里某行的内容回掉给tableView, 利用前两种方法可以去掉tableView最后一行的分割线,但当回调pickerView里的内容刷新tableView的一行时,方法1,方法2最后那个分割线就会重新显示出来,惆怅啊,在网上找了很多方法包括
包括:
方法1:

weatherOptionsTableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.001)]; //TableView 的名叫weatherOptionsTableView

方法2自定义方法隐藏
``-(void)setExtraCellLineHidden:(UITableView *)tableView{
UIView *views = [[UIView alloc] init];
views.backgroundColor = [UIColor clearColor];
[tableView setTableFooterView:views];
}
然后在ViewDidLoad()中,设置表格不可滑动,同时隐藏表尾
[self.weatherOptionsTableView setScrollEnabled:NO];
[self setExtraCellLineHidden:self.weatherOptionsTableView];

**方法3:**
设个区尾,和方法1,方法2的效果一样,且回掉的次数越多,最后的分割线越粗!
`-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{  
        return 1;        
}`

最后还是完美的解决了,
**方法4:**
定位到最后一行,然后
  if(indexPath.row ==3){
  cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, [UIScreen mainScreen].bounds.size.width);        //去掉最后一行的分割线,很管用!!!!

感谢各位网友,渣渣一枚,只是做个笔记!

猜你喜欢

转载自blog.csdn.net/baihailing/article/details/77917568
今日推荐