大型 UIImage 未缩小到滚动视图的框架中
我似乎无法使用 UIViewContentModeScaleAspectFit 属性来缩放滚动视图中的 imageView 以适应滚动视图大小。
- (void)loadView {
UIImage* image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.moilum.com/images/atomicongallery/setmenu/setmenu1.jpg"]]];
imageView = [[UIImageView alloc]initWithImage:image];
imageView.contentMode = UIViewContentModeScaleAspectFit;
CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
UIScrollView* scrollView = [[UIScrollView alloc]initWithFrame:applicationFrame];
[scrollView addSubview:imageView];
scrollView.contentSize = image.size;
scrollView.minimumZoomScale = 0.3;
scrollView.maximumZoomScale = 3.0;
scrollView.clipsToBounds = NO;
scrollView.delegate = self;
self.view = scrollView;
我也
尝试过 imageView.contentMode = UIViewContentModeScaleAspectFill 。同样,scrollView.contentmode = UIViewContentModeScaleAspectFill。一切似乎都不起作用:(
有出路吗!?
干杯!
i can't seem to use UIViewContentModeScaleAspectFit property to scale my imageView within my scrollview to fit the scrollview size.
- (void)loadView {
UIImage* image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.moilum.com/images/atomicongallery/setmenu/setmenu1.jpg"]]];
imageView = [[UIImageView alloc]initWithImage:image];
imageView.contentMode = UIViewContentModeScaleAspectFit;
CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
UIScrollView* scrollView = [[UIScrollView alloc]initWithFrame:applicationFrame];
[scrollView addSubview:imageView];
scrollView.contentSize = image.size;
scrollView.minimumZoomScale = 0.3;
scrollView.maximumZoomScale = 3.0;
scrollView.clipsToBounds = NO;
scrollView.delegate = self;
self.view = scrollView;
}
i have tried imageView.contentMode = UIViewContentModeScaleAspectFill as well. scrollView.contentmode = UIViewContentModeScaleAspectFill as well. All dont seem to work :(
any way out!?
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您没有在 UIScrollViewDelegate 上实现
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)sView
方法,UIScrollView 将不会调整其 ZoomScale。像这样的东西
(但显然根本不设置代表也有效。)
The UIScrollView will not adjust its zoomScale if you don't implement the
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)sView
method on the UIScrollViewDelegate.Something like this
(But apparently not setting a delegate at all works too.)
你有没有尝试过,
我从我的 iPad 上编写了这段代码,我认为这应该可行,
如果您有任何问题,请告诉我。
祝你好运。
Have you tried,
I write this code from my iPad i think this should work,
Let me know if you have any problem.
Good luck.