TochesBegan is not firing in xcode?
<p>I have a problem with touchesBegan event.I displayed an image in an uiimageview.Am trying to detect the touches on that image by displaying small green color points on the image when i clicked on the image..
Am not getting any errors while running but the touches event is not firing.Here is my code:</p>

<pre><code>#import &lt;UIKit/UIKit.h&gt;
#import "Second.h"
@interface pickerExampleViewController : UIViewController &lt;UIImagePickerControllerDelegate&gt;{
 IBOutlet UIButton *selectPic;

}
@property (nonatomic,retain) UIButton *selectPic;
-(IBAction)getpic:(id)sender;
@end

#import "pickerExampleViewController.h"

@implementation pickerExampleViewController
@synthesize selectPic;
-(IBAction)getpic:(id)sender
{
 UIImagePickerController *picker = [[UIImagePickerController alloc]init];
 picker.delegate = self;
 picker.editing  = YES;
 picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
 [self presentModalViewController:picker animated:YES];
 [picker release];
}

#pragma mark imagePickerController delegate methods
-(void)imagePickerController:(UIImagePickerController *) picker
    didFinishPickingImage:(UIImage *)image 
     editingInfo:(NSDictionary *)editingInfo  
{
 [picker dismissModalViewControllerAnimated:YES];
 Second *secview = [[Second alloc] initWithNibName:@"Second" bundle:nil];
 secview.view.backgroundColor = [UIColor blackColor];
 [secview setImage:image];
 [self.view addSubview:secview.view];
 //[self presentModalViewController:secview animated:YES];
 [secview release];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
 [self dismissModalViewControllerAnimated:YES];
}
@interface Second : UIViewController {
 IBOutlet UIImageView *imgView;
 UIImage *image1;
}
@property(nonatomic,retain) UIImageView *imgView;
-(void)setImage:(UIImage *)img;
-(IBAction)back;
@end
#import "Second.h"
#import &lt;QuartzCore/QuartzCore.h&gt;

@implementation Second
@synthesize imgView;
static int countoftouches,i;
CGPoint points[4];
-(void)setImage:(UIImage *)img
{
 [imgView setImage:img];
 countoftouches=0;
}
-(IBAction)back
{
 [self.view removeFromSuperview];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
 UITouch *touch = [touches anyObject];
 //NSSet *allTouches = [event allTouches]; 
 if ([touch view] != imgView) {
  return;
 }
 countoftouches++;
 CGPoint point = [touch locationInView:imgView];
 NSLog(@"x: %f, y: %f", point.x, point.y);
 CGRect frame=CGRectMake(point.x, point.y, 5, 5);
 if(countoftouches&lt;=4)
 {

  points[i] = frame.origin;
  i++;
  UIButton *btn=[[UIButton alloc]initWithFrame:frame];
  [btn setBackgroundColor:[UIColor greenColor]];
  [imgView addSubview:btn];
  [btn release];
 }

}
 -(void)dealloc
{
 [imgView release];
 [super dealloc];
}
@end
</code></pre>
