IOS 8 UITableView cell lines不能靠左解决方法

 ios7中用以下方法可使UITableView cell lines靠左

self.tableview.separatorInset = UIEdgeInsetsZero;

但在ios8中该办法已失灵啦

经过翻阅ios8文档发现用以下两种办法即可解决该问题
方法一:
- (void) viewDidLoad { [...] self.tableView.separatorInset = UIEdgeInsetsZero; if ([self.tableView respondsToSelector:@selector(layoutMargins)]) { self.tableView.layoutMargins = UIEdgeInsetsZero; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { [...] cell.separatorInset = UIEdgeInsetsZero; if ([cell respondsToSelector:@selector(layoutMargins)]) { cell.layoutMargins = UIEdgeInsetsZero; } }
方法二:
- (UIEdgeInsets)layoutMargins

{

    return UIEdgeInsetsZero;

}


 

你可能感兴趣的:(UITableView)