我想使一個滾動視圖只能在某個區域上滾動。爲此,我將UIScrollView繼承並覆蓋touchesBegan(類似於this question)。UIScrollView子類永遠不會收到touchesBegan消息的刷卡
這是我的(很簡單)代碼。
.H
@interface SuppressableScrollView : UIScrollView
@end
的.m
#import "SuppressableScrollView.h"
@implementation SuppressableScrollView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchesBegan touches=%@ event=%@", touches, event);
[super touchesBegan:touches withEvent:event];
}
@end
的touchesBegan只被稱爲該UIScrollView的不正常消耗(抽頭等)的觸摸。任何想法如何攔截所有的觸摸?
我想我錯過了某個地方的概念。