/***html
iOS8 分割線問題 在xib/storyboard下面解決方案ios
http://qiita.com/yimajo/items/10f16629200f1beb7852iphone
http://www.cocoachina.com/ios/20141026/10045.htmlui
http://www.2cto.com/kf/201411/349631.htmlspa
http://dev.classmethod.jp/smartphone/iphone/ios-8-uitableview-layoutmargins/.net
http://demo.netfoucs.com/growinggiant/article/details/42002871代理
*/code
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self.view setLayoutMargins:UIEdgeInsetsZero]; // if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) { // // [self.tableView setSeparatorInset:UIEdgeInsetsZero]; // // } // // if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) { // // [self.tableView setLayoutMargins:UIEdgeInsetsMake(0, 0, 0, 0)]; // // } // [self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)]; } -(void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) { [self.tableView setSeparatorInset:UIEdgeInsetsZero]; } if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) { // [self.tableView setLayoutMargins:UIEdgeInsetsZero]; [self.view setLayoutMargins:UIEdgeInsetsZero]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 100; } -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"TableViewCell"; UITableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (cell==nil) { UINib *nib = [UINib nibWithNibName:@"TableViewCell" bundle:nil]; [tableView registerNib:nib forCellReuseIdentifier:ID]; return [[nib instantiateWithOwner:nil options:nil]lastObject]; } // cell.preservesSuperviewLayoutMargins = NO; // if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { // cell.separatorInset = UIEdgeInsetsZero; // } // // if([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) { // cell.preservesSuperviewLayoutMargins = false; // } // // if( [cell respondsToSelector:@selector(setLayoutMargins:)]) { // cell.layoutMargins = UIEdgeInsetsZero; // [self.view setLayoutMargins:UIEdgeInsetsZero]; // } return cell; } //而後在UITableView的代理方法中加入如下代碼 //- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath // //{ // // if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { // // [cell setSeparatorInset:UIEdgeInsetsZero]; // // } // // if ([cell respondsToSelector:@selector(setLayoutMargins:)]) { // // [cell setLayoutMargins:UIEdgeInsetsZero]; // // } // //}