为什么滚动视图中的选定图像不会传递给其他视图控制器?
- (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];
}
答案 0 :(得分: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