Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to go to detail view by touch event on an image view?
    primarykey
    data
    text
    <p>i have created one photo slide show app with images from an array are displayed in a scroll view. i have added touch events to it.On touching it should be the detail view of the touched image on an UIimageView But i am not getting that by mouse click(i am running it on simulator),but i get it by alt+mouse click - at that time there are two points just as zooming on maps I know thats the correct way,so how do i get proper touch on single mouse click?</p> <p>adding the code</p> <pre><code> - (void)viewDidLoad { [super viewDidLoad]; scrollView.delegate = self; scrollView.scrollEnabled = YES; int scrollWidth = 120; scrollView.contentSize = CGSizeMake(scrollWidth,80); int xOffset = 0; imageView.image = [UIImage imageNamed:[imagesName objectAtIndex:0]]; for(int index=0; index &lt; [imagesName count]; index++) { UIImageView *img = [[UIImageView alloc] init]; img.bounds = CGRectMake(10, 10, 50, 50); img.frame = CGRectMake(5+xOffset, 0, 160, 110); NSLog(@"image: %@",[imagesName objectAtIndex:index]); img.image = [UIImage imageNamed:[imagesName objectAtIndex:index]]; [images insertObject:img atIndex:index]; scrollView.contentSize = CGSizeMake(scrollWidth+xOffset,110); [scrollView addSubview:[images objectAtIndex:index]]; xOffset += 170; } } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.nextResponder touchesBegan:touches withEvent:event]; UITouch * touch = [[event allTouches] anyObject]; for(int index=0;index&lt;[images count];index++) { UIImageView *imgView = [images objectAtIndex:index]; NSLog(@"x=%f,y=%f,width=%f,height=%f", imgView.frame.origin.x,imgView.frame.origin.y, imgView.frame.size.width,imgView.frame.size.height); NSLog(@"x= %f,y=%f",[touch locationInView:self.view].x,[touch locationInView:self.view].y) ; if(CGRectContainsPoint([imgView frame], [touch locationInView:scrollView])) { [self ShowDetailView:imgView]; break; } } } -(void)ShowDetailView:(UIImageView *)imgView { imageView.image = imgView.image; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload