【发布时间】:2011-02-18 12:17:04
【问题描述】:
如何禁用 UIScrollview 上的向左滚动。这样用户只能向右滚动?
谢谢
*** 更新 *****
这就是我现在所拥有的。我继承了 UIScrollView 并覆盖了以下方法
@implementation TouchScrollView
- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view {
NSLog(@"touchesShouldBegin: I was touched!");
return YES;
}
- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
NSLog(@"touchesShouldCancelInContentView: I was touched!");
return NO;
}
在我的 viewController 中,我还设置了以下属性:
scrollView.delaysContentTouches = NO;
scrollView.canCancelContentTouches = YES;
TouchesShouldBegin 被调用,但 touchesShouldCancelInContentView 没有被调用,我不知道为什么!!
谢谢
【问题讨论】:
-
我也有同样的问题。你知道为什么即使 id canCancelContentTouches 设置为 YES 也不会调用 canCancelContentTouches 吗?
标签: iphone objective-c xcode