0

我正在尝试通过缩放和滚动将图像放入 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;
}
4

1 回答 1

0

这是通过设置修复的

 iImgView.userInteractionEnabled = YES;
于 2013-06-17T05:25:11.113 回答