问题描述
|
我使用此代码来检测在uiview顶部的uiscrollview上的触摸
子类
.h文件
@interface AppScrollView : UIScrollView
{
}
@end
.m文件
#import \"AppScrollView.h\"
@implementation AppScrollView
- (id)initWithFrame:(CGRect)frame
{
return [super initWithFrame:frame];
}
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event
{
// If not dragging,send event to next responder
if (!self.dragging)
[self.nextResponder touchesEnded: touches withEvent:event];
else
[super touchesEnded: touches withEvent: event];
}
@end
然后在另一堂课上我加了
#import <UIKit/UIKit.h>
@class AppScrollView;
@interface SomeClass : UIViewController <UIScrollViewDelegate>
{
AppScrollView *scrollView;
...
}
@end
#import \"AppScrollView.h\"
@implementation SomeClass
...
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event
{
// Process the single tap here
...
}
...
@end
我也用了scroll1.delegate=self;
,但是什么也没发生!
谁能帮我?
解决方法
使用
Gesture Recognizers
。特别是ѭ5。