0
我用這個代碼來檢測上的UIScrollView誰是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;
但沒有任何反應!
任何人都可以幫助我嗎?
您是否僅創建子類來檢測觸摸? – 2011-05-24 15:14:21
是的,這是爲什麼我實現了子類 – stefanosn 2011-05-24 16:35:03