简体   繁体   English

如何在图像上的uiscrollview内捕获事件

[英]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. 嗨我已经用图像填充了uiscrollview(代码如下)但我不知道如何在里面的图像中添加一些事件。 I want to double tap on image inside scrollview and get some event. 我想在scrollview中双击图像并获得一些事件。 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...");

    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). 将UITapGestureRecognizer添加到UIImageView。

Look at this guide for more info. 请参阅本指南以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM