2015-04-20 45 views
0

我有一個uiwebview和一個uiview相鄰的其他任何東西都佔據了屏幕寬度的50%。從uiview到uiscrollview的複製/鏡像觸摸事件

我可以順利滾動uiwebview - 並且我希望能夠在uiview上向上/向下滾動 - uiwebview在給定方向上滾動。

已將子查看uiview - 並trie'd將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.webView嘗試過了,self.webView.scrollView 不工作 - 任何幫助嗎?

BTW:在touchesMoved內的NSLog被稱爲

問候

回答

0

確定 - 與UIScrollView的子類,這樣做是和同步的.contentOffset和.contentSize