0

In my app i have a TableView which has a header that i want to hide initially until the user scrolls the tableview. My problem is when the view loads, for 1 second you can see the tableview moving up. I dont want to see this movement. How can i achieve this correctly?

This is my code:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self performSelector:@selector(hideSearchBar) withObject:nil afterDelay:0.0f];
}

- (void)hideSearchBar 
{
    self.tblView.contentOffset = CGPointMake(0, 40);
}
user3065901
  • 4,678
  • 11
  • 30
  • 52
  • Why are you running `hideSearchBar` with `performSelector`? Have you tried without it? Also, don't forget to call `[super viewWillAppear:animated];` inside your `viewWillAppear`. – Erakk May 18 '15 at 18:25
  • Yes, i tried without it and did not work. The only way it works is using performSelector. No idea why. – user3065901 May 19 '15 at 08:10
  • Try to do it with `[self hideSearchBar];` but run this method *before* the `[super viewWillAppear:animated];` – Erakk May 19 '15 at 18:50

0 Answers0