I have two view controller. One scrollview for page control and one for detail (scroll vertical).
When i click status bar on iPhone the scrollToTop not working, and in iPad the scrollToTop is working.
I am sure that the scrollView.scrollToTop is YES. because i already print it.
Anyone know what cause the iPhone scrollToTop not working?
Thank you
Edit: I try by calling the scrollView delegate. in iPad this delegate its called. - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
in iPhone it is not called. I already use both contentScrollView.delegate = self; But the iphone not working :(
Edit: Try subclassing UIWindow (not working)
Window.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface Window : UIWindow
@end
Window.m
#import "Window.h"
@implementation Window
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if ([event type] == UIEventTypeTouches && point.y < 250) {
//Send Your Notification Here
NSLog(@"KAROOO");
}
NSLog(@"HELLOWW");
return [super hitTest:point withEvent:event];
}
@end
AppDelegate.h
@property (nonatomic, strong) IBOutlet Window *window;
AppDelegate.m
@synthesize window = _window;
If your CSS html element has the following overflow markup, scrollTop will not function. To allow scrollTop to scroll, modify your markup remove overflow markup from the html element and append to a body element.
If the address bar is hidden in Safari, you'll have to tap the status bar twice to return to the top.
Method 1: Using window.scrollTo() The scrollTo() method of the window Interface can be used to scroll to a specified location on the page. It accepts 2 parameters the x and y coordinate of the page to scroll to. Passing both the parameters as 0 will scroll the page to the topmost and leftmost point.
From what I understand you have 2 UIScrollViews simultaneously on screen.
From what I have seen & experienced, On iOS 4 having 2 UIScrollViews side by side gives undefined behaviour. One of the scrollview may scroll, sometimes other, sometimes neither.
On iOS 5 if you have 2 UIScrollViews side by side then tapping on status bar "scrolls to top" the UIScrollView right "under your tap"
I don't know how this works, but this has been my observation. iOS 5 is smart !!
If your UIScrollViews are one above other then probably the behaviour is undefined. I haven't checked.
Hope this helps.
If you want to get it working anyways then here is a possible solution.
Subclass or Add a category on UIWindow and add a gesture recognizer / or implement hitTest that detects tap only for Y < 20 and so on and then have it send a notification and listen to this in your viewController and programmatically scroll the UIScrollView to top.
EDIT
Implement this in the UIWindow subclass (iPad)
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if ([event type] == UIEventTypeTouches && point.y < 20 && [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait) {
NSLog(@"Portrait");
} else if ([event type] == UIEventTypeTouches && point.y > 1004 && [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown) {
NSLog(@"PortraitUpsideDown");
} else if ([event type] == UIEventTypeTouches && point.x < 20 && [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft) {
NSLog(@"LandscapeLeft");
} else if ([event type] == UIEventTypeTouches && point.x > 748 && [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
NSLog(@"LandscapeRight");
}
return [super hitTest:point withEvent:event];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With