UiTableview ContentInset

prajakta kulkarni picture prajakta kulkarni · Jan 31, 2012 · Viewed 8.6k times · Source

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.

Answer

Abizern picture Abizern · Jan 31, 2012

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.