我正在尝试使用缩放和滚动将图像放入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;
}
答案 0 :(得分:0)
通过设置
解决了这个问题 iImgView.userInteractionEnabled = YES;