简体   繁体   中英

UiTableview ContentInset

I am working on very small app. In this app I am using UIrootviewController's table view to display some content in it. I want that content to be displayed at particular position so I am setting its contentInset. when I do it in viewDidLoad or in xib it is not showing any effect at first time. I have written it in shouldAutorotateToInterfaceOrientation function it is giving me proper location after orientation change but at first time it is showing table content at same location whatever may be the content insets values

here is my code for setting content insets

self.tableView.contentInset = UIEdgeInsetsMake(120, 150, 0.0, 0.0);

I have wrote this code inside viewDidLoad , and shouldAutorotateToInterfaceOrientation but it is not showing any effect when application starts. is there any other method to achieve this.

i even tried setFrame, but did not worked.

I think you may be confused about what method to use. If you want to set the position and size of the view you should set its frame .

在viewDidLoad或viewWillAppear中尝试以下操作:

self.tableView.contentInset = UIEdgeInsetsMake(120.0f, 150.0f, -120.0f, -150.0f);

将您的代码放在viewWillAppear方法中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM