0

我在滚动视图下有图像视图。在具有图像的图像视图中。当我从滚动视图中单击特定图像时,该图像出现在相机视图的覆盖上。我使用 doubleTap 删除覆盖图像。当我使用双击从超级视图中删除的覆盖图像时。之后,我显示滚动视图并选择另一个图像,图像不会出现在 cameraView (覆盖)

代码:

双击手势:

UITapGestureRecognizer *doubletap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doubleTap:)];
    doubletap.numberOfTapsRequired=2;
    [myImageView addGestureRecognizer:doubletap];

UITapGestureRecognizer *doubletap1=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doubleTap1:)];
    doubletap1.numberOfTapsRequired=2;
    [myImageView1 addGestureRecognizer:doubletap1];

双击方法:

-(void)doubleTap:(UITapGestureRecognizer*)sender{

    NSLog(@"image");

    [myImageView removeFromSuperview];

}

-(void)doubleTap1:(UITapGestureRecognizer*)sender{

    NSLog(@"image1");

    [myImageView1 removeFromSuperview];

}

将图像视图添加到滚动视图:

    -(void)unloadPreviousPage:(int)index
    {



        for(int i=index*4;i<(index+1)*4;i++)
        {
            [[myScrollView viewWithTag:i+1] removeFromSuperview];

        }


    }

-(void)loadNextPage:(int)index
{


    int countFlag=0;
    for(int i=index*4;i<(index+1)*4;i++)
    {
        UIButton *imageView=[[UIButton alloc]initWithFrame:CGRectMake((320*index)+countFlag*80+ 2, 5, 75, 75)];
        imageView7.tag=i+1;
        [imageView7 addTarget:self action:@selector(imageViewClicked:) forControlEvents:UIControlEventTouchUpInside];
        //[imageView.layer setBorderColor:[UIColor lightGrayColor].CGColor];
        // [imageView.layer setBorderWidth:1.0f];
        switch ((i+1)%2) {
            case 0:
                [imageView setImage:[UIImage imageNamed:@"img.png"] forState:UIControlStateNormal];

                break;

            case 1:
                [imageView setImage:[UIImage imageNamed:@"img1.png"]  forState:UIControlStateNormal];

                break;
}

        [myScrollView addSubview:imageView];


        countFlag++;
    }
}

-(void)imageViewClicked:(id)sender{

    switch ([sender tag]%2) {
        case 0:
            [myImageView setImage:[UIImage imageNamed:@"img.png"]];
            break;

        case 1:
            [myImageView setImage:[UIImage imageNamed:@"img1.png"]];
            break;
}
}
4

0 回答 0