首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在UIScrollView的子类中编写事件方法后也不能检测到它呢?

为什么在UIScrollView的子类中编写事件方法后也不能检测到它呢?
EN

Stack Overflow用户
提问于 2009-12-05 14:39:08
回答 1查看 223关注 0票数 1

我想为UIScrollView使用触摸事件方法。但据说只有在我继承UIScrollView子类并在其中编写这些函数的情况下,我才能做到这一点。所以我这样做了

代码语言:javascript
复制
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中了。我现在该怎么做?

EN

回答 1

Stack Overflow用户

发布于 2009-12-05 14:53:13

是否将接口生成器中的UIScrollView outlet类类型更改为ImageTiling类?

此外,您最好使用NSLog(@"Ended");,而不是出于调试目的而显示UIAlertView。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1851370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档