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.
精彩评论