手势识别器无法在UIScrollView子类中工作

时间:2012-10-01 05:54:27

标签: iphone ios xcode ios5 uiscrollview

我已经将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

有谁能建议我在这里做错了什么?谢谢大家:)

0 个答案:

没有答案