为什么触摸事件方法甚至在将其写入UIScrollView的子类之后仍未检测到?

时间:2009-12-05 06:39:08

标签: iphone cocoa-touch uiscrollview

我想为UIScrollView使用触摸事件方法。但有人说,只有当我将UIScrollView子类化并在其中编写这些函数时,我才能做到这一点。所以我喜欢这个

SubClassing.h
 @interface ImageTiling : UIScrollView {
}
@end

SubClassing.m
#import "ImageTiling.h"


 @implementation ImageTiling

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Touched" message:@"YOOY" delegate:nil cancelButtonTitle:@"YES" otherButtonTitles:nil];
[alert show];
[alert release];
}



- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Ended" message:@"YOOY" delegate:nil cancelButtonTitle:@"YES" otherButtonTitles:nil];
[alert show];
[alert release];
}
@end

但它没有任何影响。我已经在main_file.h中导入了它。我现在该怎么办?

1 个答案:

答案 0 :(得分:0)

您是否已将Interface Builder中的UIScrollView插座类类型更改为ImageTiling类?

另外,你最好使用NSLog(@“Ended”);而不是为了调试目的而显示UIAlertView。