开发者

How to catch event inside uiscrollview on image

Hi I have populated uiscrollview with images (code is bellow) but I don't know how to add some event to images inside. I want to double tap on image inside scrollview and get some event. Any direction how to achieve this?

arrayOfImages = [[NSMutableArray alloc] init];
    NSString *img;
    for (img in imgArray)
    {
        [arrayOfImages addObject:[UIImage imageNamed:img]];
    }

    NSLog(@"Array initialization complete...")开发者_Go百科;

    scrollView = [[UIScrollView alloc] init];
    scrollView.scrollEnabled = YES;
    scrollView.pagingEnabled = YES;
    scrollView.directionalLockEnabled = YES;
    scrollView.showsVerticalScrollIndicator = NO;
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.delegate = self;
    scrollView.backgroundColor = [UIColor blueColor];
    scrollView.autoresizesSubviews = YES;
    scrollView.frame = CGRectMake(0, 0, 320, 29);
    [self.view addSubview:scrollView];

    NSLog(@"Scroll View initialization setup complete...");

    UIImage *imageToAdd;
    int x = 0;
    int y = 0;
    for (imageToAdd in arrayOfImages)
    {
        UIImageView *temp = [[UIImageView alloc] initWithImage:imageToAdd];     

        temp.frame = CGRectMake(x, y, 29, 29);
        x += 29;
        [scrollView addSubview:temp];

    }

    NSLog(@"Adding images to outlet complete...");


Add a UITapGestureRecognizer to the UIImageView(s).

Look at this guide for more info.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜