我想为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中了。我现在该怎么做?
发布于 2009-12-05 14:53:13
是否将接口生成器中的UIScrollView outlet类类型更改为ImageTiling类?
此外,您最好使用NSLog(@"Ended");,而不是出于调试目的而显示UIAlertView。
https://stackoverflow.com/questions/1851370
复制相似问题