开发者

Why touches Event methods not detecting even after writing it inside the subclass of UIScrollView?

开发者 https://www.devze.com 2022-12-13 12:15 出处:网络
I want to use touch event methods for UIScrollView. But it was said that I could do this only if I subclass UIScrollView and write these functions inside it. So i did like this

I want to use touch event methods for UIScrollView. But it was said that I could do this only if I subclass UIScrollView and write these functions inside it. So i did like this

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

SubClassing.m
#import "ImageTiling.h"


 @implementation ImageTiling

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UIAlertView *alert = [[UIAlertView alloc] ini开发者_如何转开发tWithTitle:@"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

But its not having any effect. I have imported that in my main_file.h. What should I do now?


Did you change your UIScrollView outlet class type in Interface Builder to your ImageTiling class?

Also, you would be better off using NSLog(@"Ended"); instead of displaying a UIAlertView for your debugging purposes.

0

精彩评论

暂无评论...
验证码 换一张
取 消