iOS 8下使用xib/storybord AutoLayout导致的分割线问题
/***
iOS8 分割线问题 在xib/storyboard下面解决方案
http://qiita.com/yimajo/items/10f16629200f1beb7852
http://www.cocoachina.com/ios/20141026/10045.html
http://www.2cto.com/kf/201411/349631.html
http://dev.classmethod.jp/smartphone/iphone/ios-8-uitableview-layoutmargins/
http://demo.netfoucs.com/growinggiant/article/details/42002871
*/
- (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]; // // } // //}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。