我已经将UIScrollView
子类化了,我的笔尖中有一个UIScrollView
,手势正常工作,但当我将Identity Inspector中的UIScrollView
类更改为我的子类时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
有谁能建议我在这里做错了什么?谢谢大家:)