2013-05-07 37 views
0

在我的应用程序,我有一个小区域,我可以拖动我的手指,并相应移动一个更大的UIScrollViewUIScrollView里面有很多按钮。无法与UIScrollView交互后setContentOffset

- - - * - - - * - - - * -

滚动型

----集装箱

--------按钮

--------按钮

--------按钮

这很有效,而UIScrollView的方式应该是这样,问题是在我拖完UIScrollView之后变得对水龙头无反应。如果我点击它上面的按钮什么都不会发生。如果我在实际UIScrollView上稍微滑动一下,它将重置到原来的位置,并且会再次响应水龙头。我很确定这是容器故障(删除它并将按钮添加到UIScrollView工程很好),但我需要具有缩放功能并向滚动视图添加容器是我知道的唯一方法。

- (void)draging:(UIControl *)c withEvent:ev { 
    UITouch *touch = [[ev allTouches] anyObject]; 
    currentTouchPoint = [touch locationInView:self.view]; 
    NSLog(@"Draging x : %f y : %f", currentTouchPoint.x, currentTouchPoint.y); 
    [_myScrollView setContentOffset:CGPointMake(currentTouchPoint.x*4, currentTouchPoint.y*2) animated:YES]; 
} 

回答

0

我结束了继承的UIScrollView和使用这样的:

#import "scrollViewWithButtons.h" 

@implementation scrollViewWithButtons 

- (BOOL)touchesShouldCancelInContentView:(UIView *)view 
{ 
    return ![view isKindOfClass:[UIButton class]]; 
} 

@end