2012-12-04 60 views
0

我有一個包含ContainerView的ScrollView。 ContainerView包含另一個用戶應該可以平移的視圖。滾動視圖中啓用用戶交互子視圖

scrollView只能垂直滾動,「容器視圖內部的視圖」可在所有方向上調整。 這裏是我

self.scrollView.contentSize = CGSizeMake(1024,1440); 
self.modelController = [self.storyboard instantiateViewControllerWithIdentifier:@"LCProduct3DViewController"]; 
self.modelController.meshIdentifier = self.meshIdentifier; 
[self addChildViewController:self.modelController]; 
self.modelController.view.frame = self.threeDView.bounds; 
[self.threeDView addSubview:self.modelController.view]; 

會發生什麼情況是,modelControler的視野之外,但滾動視圖邊界內的modelController的視圖內的觸摸事件和那些似乎得到了對方的方式。 我玩過

self.scrollView.canCancelContentTouches = NO; 
self.scrollView.delaysContentTouches = NO; 

但還沒有找到一個工作解決方案。

任何想法?

在此先感謝

回答

1

如可以在其他地方找到: 訣竅是繼承滾動視圖和重寫則hitTest方法是這樣的:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event 
{ 
    UIView* result = [super hitTest:point withEvent:event]; 

    if ([result isKindOfClass:[GLKView class]]) { 
     self.scrollEnabled = NO; 
    } else { 
     self.scrollEnabled = YES; 
    } 
    return result; 
} 

這樣 - 如果則hitTest爲innove視圖是積極的,scrollview的滾動被禁用,只有innver視圖纔會得到事件。

相關問題