2016-11-04 65 views
2

我已经设置了的tableView的contentInset的方法- (void)viewDidLoad和物业然而self.tableView.contentInset = UIEdgeInsetsMake(200, 0, 200, 0);tableView.contentInset将全自动改为:{64, 0, 0, 0} 。为什么发生这种情况,我怎么能解决售后服务这个问题?的UITableView contentInset改变

环境:XCode8.1 iOS10.1

#import "YAVideoViewController.h" 
static NSString * const ID = @"cell"; 
@interface YAVideoViewController() 

@end 

@implementation YAVideoViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 



    self.view.backgroundColor = [UIColor arcColor]; 
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:ID]; 

    self.tableView.contentInset = UIEdgeInsetsMake(200, 0, 200, 0); 
} 



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 

    return 50; 
} 



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID forIndexPath:indexPath]; 

    cell.textLabel.text = [NSString stringWithFormat:@"第%ld个cell",indexPath.row]; 

    return cell; 
} 

@end 

回答

3

您需要更改viewDidAppear或viewDidLayoutSubviews方法的内容插图。

- (void)viewDidLayoutSubviews { 
    [super viewDidLayoutSubviews]; 
    self.tableView.contentInset = UIEdgeInsetsMake(200, 0, 200, 0); 
} 
3

将此项添加到您的viewDidLoad方法中。

self.automaticallyAdjustsScrollViewInsets = NO; 
+0

在ViewController的属性检查器中也可以不选中。 – user2071152

相关问题