11

I inserted a UITableView inside another UIViewController's view. but when I tap the status bar at the top of the screen; the table view doesn't scroll to the top which is the expected behavior within iOS apps.

I tried :

[self.tableView setScrollsToTop:YES];

but the tableview still not scroll to top when tap the top of the screen.

Cameron Lowell Palmer
  • 21,528
  • 7
  • 125
  • 126
yasserislam
  • 123
  • 1
  • 2
  • 7
  • Do you have multiple scroll views on screen? (A `UITableView` is a scroll view. So is a `UITextView`.) – rob mayoff Jan 21 '12 at 07:26
  • i have uiviewcontroller which contains multiple views, one of them is UITableView, but when i tap the top of the screen, this UITableView doesn't scroll to top, is there notification message sent from top bar when the user tapping it? – yasserislam Jan 22 '12 at 05:49
  • 1
    You didn't answer my question. Do you have **multiple** scroll views on screen? Keep in mind that `UITextView` is also a scroll view. – rob mayoff Jan 22 '12 at 05:50
  • BTW, there is no public notification when the status bar is tapped. – rob mayoff Jan 22 '12 at 05:51
  • i don't have multiple scroll views, this tableview only is the scroll. – yasserislam Jan 22 '12 at 05:53
  • sorry, there are other UItableViews in the background – yasserislam Jan 22 '12 at 08:54

2 Answers2

45

You have to set scrollsToTop to NO on all the other scroll views in your hierarchy. If more than one scroll view has scrollsToTop set to YES, none of them will scroll to top when the status bar is touched. This is mentioned in the documentation of the scrollsToTop property.

Keep in mind that this also applies to any subclasses of UIScrollView in your view hierarchy, and that UITableView, UIContainerView, and UITextView are subclasses of UIScrollView.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
0

Thanks for all, i resolved this problem by removing all other UITableView from the parent ViewController, and then auto scroll to top was working for this UITableView..

thanks

yasserislam
  • 123
  • 1
  • 2
  • 7