UIWebView Scroll delegate
-
hey all. i have an UIWebView(tarayici in my situation) in view controller. it works fine when its scroll view delegate is not assigned to view controller. but i need to know when it is scrolled that is why i wrote this code.
self.tarayici.scrollView.delegate = self;
but when i write this down then webview acts so weird. for example after this code when i want to scroll then it scrolls only once if i make 3 or 4 attempts. so how can make it work more efficient with that code ?
-
hey all. i have an UIWebView(tarayici in my situation) in view controller. it works fine when its scroll view delegate is not assigned to view controller. but i need to know when it is scrolled that is why i wrote this code.
self.tarayici.scrollView.delegate = self;
but when i write this down then webview acts so weird. for example after this code when i want to scroll then it scrolls only once if i make 3 or 4 attempts. so how can make it work more efficient with that code ?
Before you added your
UIWebView
did you set the user interaction??webView.userInteraction = YES; // down here is where you add it as a child
-
Before you added your
UIWebView
did you set the user interaction??webView.userInteraction = YES; // down here is where you add it as a child
i think i found the solution. The commented UIview animation block locked the main thread i think that is why Scroll View couldnt response to the new touches. but with this new animation block it works well.
- (void) scrollViewDidScroll:(UIScrollView *)scrollView
{if (self.lastContentOffset > scrollView.contentOffset.y) { if (self.altView.frame.size.height + self.altView.frame.origin.y > self.screenHeight) {
// [UIView animateWithDuration:0.5f animations:^{
// self.altView.frame = CGRectMake(0, self.altView.frame.origin.y-1, 320, 48);
// self.tarayici.frame = CGRectMake(0, self.tarayici.frame.origin.y, 320, self.tarayici.frame.size.height-1);
// }];\[UIView animateWithDuration:0.5f delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ self.altView.frame = CGRectMake(0, self.altView.frame.origin.y-1, 320, 48); self.tarayici.frame = CGRectMake(0, self.tarayici.frame.origin.y, 320, self.tarayici.frame.size.height-1); } completion:^(BOOL finished) { }\]; } } else if (self.lastContentOffset < scrollView.contentOffset.y) { if (self.altView.frame.origin.y < self.screenHeight) {
// [UIView animateWithDuration:0.5f animations:^{
// self.altView.frame = CGRectMake(0, self.altView.frame.origin.y + 1, 320, 48);
// self.tarayici.frame = CGRectMake(0, self.tarayici.frame.origin.y, 320, self.tarayici.frame.size.height+1);
// }];
[UIView animateWithDuration:0.5f delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
self.altView.frame = CGRectMake(0, self.altView.frame.origin.y + 1, 320, 48);
self.tarayici.frame = CGRectMake(0, self.tarayici.frame.origin.y, 320, self.tarayici.frame.size.height+1);
} completion:^(BOOL finished) {}\]; } } self.lastContentOffset = scrollView.contentOffset.y;
}