duplicate/mirror 从 uiview 到 uiscrollview 的触摸事件

duplicate/mirror touch events from uiview to uiscrollview

我有一个 uiwebview 和一个 uiview 彼此相邻,每一个都占据了屏幕宽度的 50%。

我可以流畅地滚动 uiwebview - 我希望能够在 uiview 上滚动 up/down - uiwebview 向给定的方向滚动。

已经子类化了 uiview - 并尝试将 touchesEnded... 事件发送到 webview.scrollview。

.h

@interface UIViewScrollDispatcher : UIView
@property(nonatomic, assign) id scroller;

.m

@implementation UIViewScrollDispatcher

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
   [self.scroller touchesCancelled:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
   [self.scroller touchesEnded:touches withEvent:event];
} 

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        [self.scroller touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{ 
    NSLog(@"TOUCHHHH %@", self.scroller);
    [self.scroller touchesMoved:touches withEvent:event];

}

像这样使用它:

UIViewScrollDispatcher * rightarea = [[UIViewScrollDispatcher alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
rightarea.backgroundColor=[UIColor redColor];
rightarea.scroller=self.webView.scrollView;

尝试使用 self.webViewself.webView.scrollView 不起作用 - 有帮助吗?

顺便说一句:调用 touchesMoved 中的 NSLog

问候

好的 - 使用 uiscrollview 子类完成并同步 .contentOffset 和 .contentSize