Ios UIScrollView上的子视图上的触摸事件

Ios UIScrollView上的子视图上的触摸事件,ios,objective-c,uiscrollview,Ios,Objective C,Uiscrollview,我在UIScrollView中创建了许多子视图。让我将每个子视图称为一个单元。每个单元格中都有一个UILabel 然后,我在单元格类上实现了touchEnd方法,希望我的应用程序在我点击任何单元格时都能响应我的触摸。然而,我无法从所有细胞中得到反应。在ScrollView中,我只能从手机底部上方的单元格(iPhone 5是568左右)获得响应,而ScrollView的contentsize是2300*1000,这意味着y=568以下的单元格不会对我的触摸做出响应。我怎样才能解决这个问题?这是我在

我在UIScrollView中创建了许多子视图。让我将每个子视图称为一个
单元
。每个单元格中都有一个UILabel

然后,我在
单元格
类上实现了touchEnd方法,希望我的应用程序在我点击任何单元格时都能响应我的触摸。然而,我无法从所有细胞中得到反应。在ScrollView中,我只能从手机底部上方的单元格(iPhone 5是568左右)获得响应,而ScrollView的contentsize是2300*1000,这意味着y=568以下的单元格不会对我的触摸做出响应。我怎样才能解决这个问题?这是我在
单元
类中的touchEnd方法

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (![self.unit.text isEqualToString:@"?"]) {
        [self.soundManager playSoundForUnit:self.unit];
    }
}

您必须设置CustomScrollView:

.h:


试试我的答案……它会有用的
@protocol CustomScrollViewDelegate <NSObject>

@optional
// optional becuase we always don't want to interact with ScrollView

- (void) customScrollViewTouchesEnded :(NSSet *)touches withEvent:(UIEvent *)event;

@end

@interface CustomScrollView : UIScrollView

@property (weak, nonatomic) id<CustomScrollViewDelegate> touchDelegate;
// delegate was giving error becuase name is already there in UIScrollView 

@end
#import "CustomScrollView.h"

@implementation CustomScrollView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{

    if (!self.dragging) {
        //NSLog(@"touchesEnded in custom scroll view");
        if (_touchDelegate != nil) {
            if ([_touchDelegate respondsToSelector:@selector(customScrollViewTouchesEnded:withEvent:)]) {
                [_touchDelegate customScrollViewTouchesEnded:touches withEvent:event];
            }
        }
    }

    else {
        // it wouldn't be called becuase at the time of dragging touches responding stops.
        [super touchesEnded:touches withEvent:event];
    }

}

@end