但是在ios8中,設置setSeparatorInset:UIEdgeInsetsZero 已經不起作用了。下面是解決辦法:
首先在viewDidLoad方法加入以下代碼:
if(leftTable!.respondsToSelector("setLayoutMargins:")){leftTable?.layoutMargins=UIEdgeInsetsZero}if(leftTable!.respondsToSelector("setSeparatorInset:")){leftTable!.separatorInset=UIEdgeInsetsZero;}
然后在UITableView的代理方法中加入以下代碼:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {if(cell!.respondsToSelector("setLayoutMargins:")){cell!.layoutMargins=UIEdgeInsetsZero}if(cell!.respondsToSelector("setSeparatorInset:")){cell!.separatorInset=UIEdgeInsetsZero;}}
這樣不出意外的話,Table的分割線就沒有空白間距了。
以上內容給大家介紹了ios8 UITableView設置 setSeparatorInset UIEdgeInsetsZero不起作用的解決辦法(去掉15px空白間距),希望對大家以上幫助!
新聞熱點
疑難解答