Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrollsToTop not working

I have the following object structure:

  • UITabBarController
    • UINavigationController
      • UITableViewController

It used to work, but then I added the UITabBarController into the mix and made a bunch of other large changes and somewhere in between it stopped.

So far I have:

  • created a new project with that structure, and that seems to work OK.
  • checked that there's only one view with scrollsToTop
  • tried adding a new UITableViewController directly under UITabBarController... still doesn't work.

One thing that might be of use is that -scrollViewShouldScrollToTop: isn't even being called, even though the table view controller's tableView.delegate is set to the controller.

like image 567
Jaka Jančar Avatar asked Jun 30 '09 11:06

Jaka Jančar


2 Answers

Just came across this problem myself.

If, like me, you started from the tab bar template Apple provides, then you have to add the following line to applicationDidFinishLaunching: in your app delegate:

[window makeKeyAndVisible];

This one line is what fixed it for me.

like image 112
T . Avatar answered Nov 16 '22 17:11

T .


I added following line to UITableViewController.

[self.navigationController.parentViewController.view.window makeKeyAndVisible];
like image 1
JFK Avatar answered Nov 16 '22 17:11

JFK