0

为什么从滚动视图中选择的图像不传递给另一个视图控制器?

- (void)tap:(UITapGestureRecognizer *)gesture{

    CGPoint touchPoint = [gesture locationInView:_scroller];

    int tapOnView = (touchPoint.x / 1024) + 1;

    NSString *imageName = [NSString stringWithFormat:@"S%d.png", tapOnView];

    UIImage *photo = [UIImage imageNamed:imageName];

    NSLog (@"the image selected is %@",imageName);

    PaintViewController *paintVC = [self.storyboard instantiateViewControllerWithIdentifier:@"paintViewController"];
    [paintVC.tempDrawImage setImage: photo];
    [self.navigationController pushViewController:paintVC animated:YES];    
}

链接到我的项目

4

1 回答 1

0

tap您可以通过以下方法替换该方法

- (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture{

    CGPoint touchPoint = [gesture locationInView:scrollView];

    NSUInteger touchedPage = floorf(touchPoint.x / scrollView.frame.size.width);
    if ([imageArray count] > 1) {

        touchedPage = touchedPage % ([imageArray count] - 1);
    }

    //Push the image to another view
于 2013-12-13T03:16:19.960 回答