Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIScrollView与UIImageView。图像不会向上滚动_Ios_Objective C_Uiscrollview_Uiimageview - Fatal编程技术网

Ios UIScrollView与UIImageView。图像不会向上滚动

Ios UIScrollView与UIImageView。图像不会向上滚动,ios,objective-c,uiscrollview,uiimageview,Ios,Objective C,Uiscrollview,Uiimageview,以下是UIScrollView、UIImageView的代码。 选择下一个映像时,将调用resetStatusImage。statusMessageImageView作为视图返回,用于放大UIScrollView委托。 使用最小缩放时,图像无法向上滚动,但仍有图像部分需要滚动。对于底部、左侧和右侧,它们完全可见,不能分别向下、向左和向右滚动。为什么图像在最小放大时不能向上滚动 - (void)viewDidLoad { CGRect r = CGRectMake(0, 0, self.s

以下是UIScrollView、UIImageView的代码。 选择下一个映像时,将调用resetStatusImage。statusMessageImageView作为视图返回,用于放大UIScrollView委托。 使用最小缩放时,图像无法向上滚动,但仍有图像部分需要滚动。对于底部、左侧和右侧,它们完全可见,不能分别向下、向左和向右滚动。为什么图像在最小放大时不能向上滚动

- (void)viewDidLoad
{
    CGRect r = CGRectMake(0, 0, self.statusMessageTextView.bounds.size.width, 455);
    statusMessageImageView = [[UIImageView alloc] initWithFrame:r];
    statusMessageImageView.contentMode = UIViewContentModeCenter;

    // Set up the scroll view for the image zooming in/out and scrolling.
    imgScrollView = [[UIScrollView alloc] initWithFrame:statusMessageImageView.bounds];
    [imgScrollView setScrollEnabled:YES];
    [imgScrollView setClipsToBounds:YES];

    [self.view addSubview:imgScrollView];

    [imgScrollView setBackgroundColor:[UIColor yellowColor]];

    [imgScrollView setContentSize:statusMessageImageView.frame.size]; // this is your image view size
    imgScrollView.delegate = self;

    UITapGestureRecognizer *doubleTapRecognizer =
        [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollViewDoubleTapped:)];
    doubleTapRecognizer.numberOfTapsRequired = 2;
    doubleTapRecognizer.numberOfTouchesRequired = 1;
    [imgScrollView addGestureRecognizer:doubleTapRecognizer];

    [imgScrollView addSubview:statusMessageImageView];
    [imgScrollView addSubview:self.statusMessageTextView];
}
- (void)resetStatusImage
{
    imgScrollView.zoomScale = 1.0;

    UIImage *statusImage = self.statusImageManager.currentStatusImage;
    NSLog(@"Image size %f %f", statusImage.size.width, statusImage.size.height);

    // Set the image view fram size equal to the image size.
    statusMessageImageView.frame = (CGRect){.origin=CGPointMake(0.0f, 0.0f), .size=statusImage.size};
    [statusMessageImageView setImage:statusImage];

    // Set the scroll view content size and zoom scale.
    imgScrollView.contentSize = statusImage.size;
    CGFloat scaleWidth = imgScrollView.frame.size.width / imgScrollView.contentSize.width;
    CGFloat scaleHeight = imgScrollView.frame.size.height / imgScrollView.contentSize.height;
    CGFloat maxScale = MAX(scaleWidth, scaleHeight);
    imgScrollView.minimumZoomScale = maxScale;
    imgScrollView.maximumZoomScale = 1.0f;
    imgScrollView.zoomScale = maxScale;

    // Save current scroll view content data
    // to detect that the user changed the visible area.
    contentOffsetX = imgScrollView.contentOffset.x;
    contentOffsetY = imgScrollView.contentOffset.y;
    zoomScale = imgScrollView.zoomScale;
}

这将对您有所帮助。

状态消息文本查看高度值出错。此外,禁用的自动缩放会在缩放、移动图像时影响statusMessageTextView的位置:文本视图也会移动

但是这对他有什么帮助呢?你能补充更多的信息吗?
-(UIView *) viewForZoomingInScrollView:(UIScrollView *)inScroll {
 return imageView;
 }