【发布时间】:2011-12-04 23:47:40
【问题描述】:
我正在尝试限制 UIScrollview 的滑动区域,但我无法做到。
我想将滑动区域仅设置到 UIScrollview 的顶部,但我想将所有内容设置为可见。
更新:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if ([touches count] > 0) {
UITouch *tempTouch = [touches anyObject];
CGPoint touchLocation = [tempTouch locationInView:self.categoryScrollView];
if (touchLocation.y > 280.0)
{
NSLog(@"enabled");
self.categoryScrollView.scrollEnabled = YES;
}
}
[self.categoryScrollView touchesBegan:touches withEvent:event];
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
// [super touchesEnded:touches withEvent:event];
self.categoryScrollView.scrollEnabled = YES;
[self.categoryScrollView touchesBegan:touches withEvent:event];
}
解决方案: 不要忘记在 UIScrollView 上将 delaysContentTouches 设置为 NO
self.categoryScrollView.delaysContentTouches = NO;
【问题讨论】:
-
不错的一个! 2 年后你帮助了我:P
标签: ios xcode uiscrollview swipe