Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS6 ScrollBarShouldScrollToTop not firing/ ScrollView Delegate issue

I am adding a dummy ScrollView to my app to detect a user click on the status bar, to performa an event in my program.. I am creating it in the ViewDidLoad:

//Dummy Scroll is for the tap on status bar to work 

UIScrollView *dummyScrollView = [[UIScrollView alloc] init]; 
dummyScrollView.delegate = self; 
[[self view ] addSubview:dummyScrollView]; 
[[self view] sendSubviewToBack:dummyScrollView];  

I then implement :

 - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView 
 { 

NSLog(@"scrollViewShouldScrollToTop");
 .
 .
 }

Under all previous versions of IOS this has worked beautifully and flawlessly, yet under iOS 6 the scrollViewShouldScrollToTop never gets called. Is this a bug?? The API says this should still be available as part of the delegate in iOS6, yet under iOS6 on both device and simulator it never executes... Anyone have any idea what is going on?

Still no other TableView or ScrollView, but there is a MAPVIEW?? But the MapView doesn't have a shouldScrollToTop that I can find to set to NO.. so I am still beyond confused why this stopped working under iOS 6...

like image 840
Speckpgh Avatar asked Sep 24 '12 03:09

Speckpgh


1 Answers

Is there any chance that the UIScrollView you're creating isn't somehow the only UIScrollView in your view hierarchy? It looks like in iOS6, if you have more than a single UIScrollView in your view hierarchy, only one should have scrollsToTop = YES. This is the one that'll have its scrollViewShouldScrollToTop method called.

My problem was similar in that I had a very basic UITableView that would no longer autoscroll to the top when the status bar was tapped. I finally remembered that one of the cells in my tableView uses a UIWebView, and that the cell's webView.scrollView was (correctly, now in iOS6) hijacking the call to scrollViewShouldScrollToTop that, before iOS6, was being made on my tableView.

After setting the tableViewCell's "scrollsToTop = NO", the status bar autoscroll once again worked as it did before. Here's more-or-less how the code looks:

myCustomCellWithAWebView.webView.scrollView.scrollsToTop = NO;

Hope this helps!

like image 145
John Jacecko Avatar answered Sep 29 '22 23:09

John Jacecko