2016-11-04 5 views
2

が、私は方法- (void)viewDidLoadでのtableViewのcontentInsetを設定して変更し、プロパティがtableView.contentInsetがに自動に変更されます、しかしself.tableView.contentInset = UIEdgeInsetsMake(200, 0, 200, 0); です:これが起こっ{64, 0, 0, 0} .Why、そしてどのように私はこの問題をsloveすることができますか?の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

関連する問題