I want to touch on UIImageView and that image display in another view in full size using navigate the view. same as gallery in mobile. just creating demo programmatically. because I'm new in iphone developing.
Here is my code.
- (void)viewDidLoad
{
NSLog(@"Enter in viewDidLoad method");
UIScrollView * scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
scroll.contentSize = CGSizeMake(320, self.view.frame.size.height+50);
[self.view setUserInteractionEnabled:YES];
[scroll setUserInteractionEnabled:YES];
[self.view addSubview:scroll];
int x=5;
int y=5;
int hei=100;
int wid=100;
int k=1;
for (int i=0; i<3; i++)
{
for(int j=0;j<50;j++)
{
imageView = [[UIImageView alloc]initWithFrame:CGRectMake((x+wid)*i+5, (y+hei)*j+5, wid, hei)];
[imageView setImage:[UIImage imageNamed:@"Motocross.png"]];
[imageView setUserInteractionEnabled:YES];
scroll.contentSize = CGSizeMake(320,(y+hei)*j+hei*2);
[imageView setTag:k];
[scroll addSubview:imageView];
NSLog(@"The tag is == %d",k++);
NSLog(@" (%d,%d)x == %d",i,j,(x+wid)*i+5);
NSLog(@" (%d,%d)y == %d",i,j,(y+hei)*j+5);
}
}
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"Exit from viewDidLoad method");
}
//Navigate on touch the imageView.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"Enter in touchesBeganWithEvent method");
UITouch *touch = [touches anyObject];
if ([touch view] == imageView)
{
NSLog(@"Enter in if condition of touch");
DetailViewController *detailViewController = [[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:nil];
detailViewController.imageD = imageView.image;
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
NSLog(@"Exit from if condition of touch");
}
NSLog(@"Exit from touchesBeganWithEvent method");
}
I want to tap on imageView and view will navigate to detailViewController and display that image in big size. but this touchesBegan method not called when i tap on imageView. In this i'm not creating array of UIImageView just alloc init in loop.. Thank you!