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;
,但是什么也没发生! 谁能帮我?     

解决方法

使用
Gesture Recognizers
。特别是ѭ5。     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...