Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios first cell is not start from top of UITableView

My Application has a navigation and UITableView. I set backgroundColor to my tableView. Look at the picture bellow. I don't understand why the first cell is not started from top of UITableView. When I use View Debbuger in Xcode, TableViewWrapperView is not fulled in UITableView.

I already searched many times. I removed check Adjust Scroll View Insets and set .zero tableview's contentinsets. At last I made New Project and make it again but I can't.

How can I resolve this problem!!

enter image description here

like image 987
Lee Dong Kyoo Avatar asked Nov 09 '16 12:11

Lee Dong Kyoo


3 Answers

Simple Solution for this issue

No need to code for this issue. Just follow below simple step

YourStoryboard.storyboard > YourViewController > Attributes inspector > Uncheck - Adjust scroll view insets.

Here I attached screenshot for reference.

enter image description here

If you like go with code I have also solution :)

- (void)viewDidLoad {
      self.automaticallyAdjustsScrollViewInsets = false
}
like image 83
Vivek Avatar answered Oct 19 '22 03:10

Vivek


This is for the souls like me who tried everything above and might have missed this. I accidentally used tableview style as Grouped instead of Plain.

So set your Tableview style to "Plain" instead of "Grouped" in xib/storyboard or in code as

Objective C

self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];

Swift 4,0

self.tableView = UITableView(frame: CGRect.zero, style: .plain)
like image 35
Dhilip Avatar answered Oct 19 '22 03:10

Dhilip


The table view tries to adjust itself to accommodate the navigation bar assuming that navigation bar is translucent and it has to display itself behind it.

To resolve this issue in the storyboard/xib file set the view controller property extends edges under top bar to false as shown below.

enter image description here

like image 5
Windindi Avatar answered Oct 19 '22 03:10

Windindi