gpt4 book ai didi

iphone - 捏缩放在 ios7 中的多图像 UIScrollview 中不起作用

转载 作者:行者123 更新时间:2023-12-03 19:43:31 25 4
gpt4 key购买 nike

我想在 uiscrollview 图像中捏缩放。我在 uiscrollview 中添加了多个图像但捏缩放不起作用我想捏缩放 UIImageview 图像。我已经引用了很多引用资料,但仍然不起作用

提前致谢

我的代码:-

for(int i = 0;i<aryImage.count;i++)
{

//Create a uiimageview

imageView =[[UIImageView alloc]init ];

imageView.frame = CGRectMake((280 *i),0.0, 280, 475);
imageView.image = [UIImage imageNamed:@"default.png"];
imageView.tag = i;
imageView.userInteractionEnabled = YES;
[scrollGallery addSubview:imageView];

scrollGallery.minimumZoomScale = 1.0;

scrollGallery.maximumZoomScale = 2.0;

scrollGallery.delegate = self;

[scrollGallery addSubview:imageView];

}
scrollGallery.contentSize = CGSizeMake(280 * aryImage.count, scrollGallery.frame.size.height);
pageControl.numberOfPages = aryImage.count;
pageControlBeingUsed = NO;
pageControl.currentPage = 0;




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

最佳答案

试试这个:

- (void)scrollViewDidZoom:(UIScrollView *)sv
{
UIView* zoomView = [sv.delegate viewForZoomingInScrollView:sv];
CGRect zvf = zoomView.frame;
if(zvf.size.width < sv.bounds.size.width)
{
zvf.origin.x = (sv.bounds.size.width - zvf.size.width) / 2.0;
}
else
{
zvf.origin.x = 0.0;
}
if(zvf.size.height < sv.bounds.size.height)
{
zvf.origin.y = (sv.bounds.size.height - zvf.size.height) / 2.0;
}
else
{
zvf.origin.y = 0.0;
}
zoomView.frame = zvf;
}

关于iphone - 捏缩放在 ios7 中的多图像 UIScrollview 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20392542/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com