0

When presenting a modal view controller that has a UIScrollView or a subclass of UIScrollView like UITableView or UICollectionView and using UIModalPresentationStyleOverCurrentContext the presented controllers scrollview doesn't scroll to the top when the status bar is tapped, this behaviour happens in iOS8 but not in iOS7.

Arnas
  • 329
  • 4
  • 16

1 Answers1

1

One reason why scrolling to the top when tapping the status button doesn't happen is having multiple scroll views. Only one scrollView in a controller should have scrollsToTop enabled while all other scroll views should have it disabled. While this doesn't happen in iOS7, in iOS8 if the presenting controller has a scrollview with scrollsToTop enabled, the presented controller's scrollView won't scroll to the top. Since viewWillAppear,viewWillDisappear are not called when presenting a modal view controller over current context the scroll view in the presenting controller should have it's scrollsToTop property disabled and if desired have a callback that would allow the presented controller to reenable it.

Arnas
  • 329
  • 4
  • 16
  • I have the same issue. My UIViewController contains only the tableview, no scrollview, no textview... I don't have multiple scrollviews (if I have, I don't see it) To be sure I use this method in Swift : http://stackoverflow.com/questions/4167806/automatic-scroll-to-top-doesnt-work-in-uitableview but same result, it doesn't work. – cmii Sep 04 '15 at 19:58
  • @cmi can't really say anything without knowing your view hierarchy, my issue was that even though they're separate controllers, when using ModalPresentationStyleOverCurrentContext in iOS8 only one tableview could have scrollsToTop = true at a time, so just before presenting a new controller I set scrollsToTop on my tableView to false. – Arnas Sep 05 '15 at 09:44