使用缩放和滚动的imageview无法使用UIViewContentModeScaleAspectFill

时间:2013-06-14 10:40:43

标签: iphone ios ipad

我正在尝试使用缩放和滚动将图像放入imageview。但是当我将contentmode设置为UIViewContentModeScaleAspectFill图像时,修复并缩放和滚动可用。任何原因我得到这种行为?下面是代码

 UIImage* image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"b3.jpg" ofType:nil]];

        iScrollView = [[UIScrollView alloc] initWithFrame:CGRectZero];
        [iScrollView setBackgroundColor:[UIColor yellowColor]];

        iScrollView.delegate = self;
        // Disabling panning/scrolling in the scrollView
        iScrollView.scrollEnabled = YES;

        iImgView = [[UIImageView alloc] initWithImage:image];
        iImgView.contentMode = UIViewContentModeScaleAspectFill;
        [iScrollView addSubview:iImgView];
        [self addSubview:iScrollView];


- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return iImgView;
}

1 个答案:

答案 0 :(得分:0)

通过设置

解决了这个问题
 iImgView.userInteractionEnabled = YES;