uiscrollview 子类检测触摸不起作用
我使用这段代码来检测位于 uiview
子类
.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
之上的 uiscrollview 的触摸,然后在我添加的另一个类上
#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;
但没有任何反应! !!
谁能帮助我吗?
i used this code to detect touch on an uiscrollview who is on top of uiview
subclass
.h file
@interface AppScrollView : UIScrollView
{
}
@end
.m file
#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
and then on another class i added
#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
i used also scroll1.delegate=self;
but nothing happens!!!
Can anyone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
手势识别器
< /a>.具体来说UITapGestureRecognizer
。Use
Gesture Recognizers
. SpecificallyUITapGestureRecognizer
.