码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 8下使用xib/storybord AutoLayout导致的分割线问题

时间:2015-04-29 21:04:33      阅读:1059      评论:0      收藏:0      [点我收藏+]

标签:

/***

  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];
//        
//    }
//    
//}

 

iOS 8下使用xib/storybord AutoLayout导致的分割线问题

标签:

原文地址:http://www.cnblogs.com/zhyios/p/4466784.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!