我刚刚看了您编辑中的指南,我想我可以看到问题所在。有关类似问题,请参阅此答案。
您的UIScrollView
子类将如下所示:
#import "AppScrollView.h"
@implementation AppScrollView
- (id)initWithFrame:(CGRect)frame
{
return [super initWithFrame:frame];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"AppScrollView touchesEnded:withEvent:");
// If not dragging, send event to next responder
if (!self.dragging)
[[self.nextResponder nextResponder] touchesEnded:touches withEvent:event];
else
[super touchesEnded: touches withEvent: event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"AppScrollView touchesMoved:withEvent:");
[[self.nextResponder nextResponder] touchesMoved:touches withEvent:event];
}
@end
包含AppScrollView
对象的类应该采用UIScrollViewDelegate
协议并实现这些方法:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"SomeClass touchesMoved:withEvent:");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"SomeClass touchesEnded:withEvent:");
}
然后记录的输出将如下所示:
2013-06-11 10:45:21.625 Test[54090:c07] AppScrollView touchesMoved:withEvent:
2013-06-11 10:45:21.625 Test[54090:c07] SomeClass touchesMoved:withEvent:
2013-06-11 10:45:21.642 Test[54090:c07] AppScrollView touchesMoved:withEvent:
2013-06-11 10:45:21.642 Test[54090:c07] SomeClass touchesMoved:withEvent:
2013-06-11 10:45:21.655 Test[54090:c07] AppScrollView touchesEnded:withEvent:
2013-06-11 10:45:21.656 Test[54090:c07] SomeClass touchesEnded:withEvent: