問題1:
在ios中使用UITableView時,當行數較少是,可能一屏幕能顯示完全所有行,這時候會出現下面的問題,顯示多余的分隔線
圖如下:
解決方案:
//解決方案1//添加如下代碼-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 0.1;}//解決方案2//添加如下代碼 UIView* v = [[UIView alloc]init]; // v.backgroundColor = [UIColor clearColor]; // _tableview.tableFooterView = v; self.myTableView.tableFooterView = v;
效果如下
在實現了上面的功能后,我發現在ios7中,分隔符不能完全填充整個UITableView,有了以下解決方案:
UIEdgeInsets edgeInset = self.myTableView.separatorInset; self.myTableView.separatorInset = UIEdgeInsetsMake(edgeInset.top, 0, edgeInset.bottom, edgeInset.right);//修改分隔線長度 self.myTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
效果如下:
希望能幫助到遇到同樣問題的朋友。
如果你有更好的解決方案,歡迎分享。
新聞熱點
疑難解答