3

I Know this is a repeated question, but I have tried all searched answers,

such as: iPhone: Hide UITableView search bar by default

but when i try this:

[self.tableView setContentOffset:CGPointMake(0, 44)];

there's a flicker on the top(Navigation's position) when push to this viewcontroller.

because at the begin, my tablecell number is 0, so I cannot use this:

[yourTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
Community
  • 1
  • 1
Chris
  • 581
  • 3
  • 17

1 Answers1

0

There is a flicker because you don't have enough rows to fill the content size of the tableView, and iOS will adjust the inset automatically in this situation.

The scrollToRowAtIndexPath method doesn't work in this case, either.

The only solution I got so far is inserting enough empty cells to the tableView. By doing so, the content size is big enough, and iOS won't set the inset.

Here is a Swift example. Although it's in Swift, the idea is the same. You can translate it into Objective-C easily.

Community
  • 1
  • 1
Brian
  • 30,156
  • 15
  • 86
  • 87