我有子类UIScrollView
,并且UIScrollView
我的笔尖中有一个,手势工作正常,但是当我将UIScrollView
Identity Inspector 中的类更改为我的子类时UIScrollView
,手势停止工作,并且我的界面生成器中有这个警告。
ScrollView does not have an outlet collection named gestureRecognizors.
我的子类中还有一个代表,它也发出警告:
这是子类:
@protocol ScrollViewDelegate <NSObject>
-(void)onScrollViewTouch;
@end
@interface ScrollView : UIScrollView <UIScrollViewDelegate>
@property(nonatomic, retain) id<ScrollViewDelegate> subDelegate;
@end
这是 ScrollView.m
@implementation ScrollView
@synthesize subDelegate;
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.canCancelContentTouches = NO;
self.delaysContentTouches = NO;
[self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[super setDelegate: self];
}
return self;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
[delegate onScrollViewTouch];
}
@end
谁能建议我在这里做错了什么?感谢大家 :)