I want to get the scroll direction in webView. I read the code about getting scroll direction here.
-(void)userDidScrollWebView:(id)scrollPoint{
// NSLog(@"scrolled:::");
NSString *x1 = [webView stringByEvaluatingJavaScriptFromString: @"scrollX"];
NSString *y1 = [webView stringByEvaluatingJavaScriptFromString: @"scrollY"];
NSLog(@"scroll x=%@ y=%@", x1,y1);
if ([y1 isEqualToString: @"0"]) {
NSLog(@"RELAOD ME");
}
}
I have 2 Questions :-
About this code,I don't know where to call userDidScrollWebView
method in my code so that I get regular updates about scrolling.
Another approach, I thought may be I could place Swipe Gesture over Web View but that's not working.
This is how I implemented swipe gesture in UIWebView.
<UIGestureRecognizerDelegate>
protocol to ViewController.h
In ViewDidLoad
Method add the following code:
UISwipeGestureRecognizer * swipeGestureDown = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeDown)];
swipeGestureDown.numberOfTouchesRequired = 1;
swipeGestureDown.direction = UISwipeGestureRecognizerDirectionDown;
swipeGestureDown.delegate = self;
[self.webView addGestureRecognizer:swipeGestureDown];
Add Delegate method in ViewController.m
:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
-(void)swipeDown
{
NSLog(@"swipe down in webView");
}
Similarly you can add another gesture for swipe Up.