滚动视图中的图像 [英] Image In Scroll View
本文介绍了滚动视图中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码尝试在 UIScrollView 中显示图像.
I am using the following code to try and display an image in a UIScrollView.
[self.jarView addSubview:imgView];
它不起作用.但是,当我将子视图添加到我的普通视图时,它会起作用.我的 UIScrollView 被称为 jarView 和 imgView 是一个 UIImageView.
It does not work. However, it works when I add the subview to my normal view. My UIScrollView is called jarView and imgView is a UIImageView.
谢谢
推荐答案
这对我来说很好:
UIScrollView *scrollview;
scrollview= [[UIScrollView alloc] initWithFrame:CGRectMake(,,,)];// set scroll view size
view = [[UIView alloc] initWithFrame:CGRectMake(y1,x1,y2,x2)]; //set the view size
UIImage *image1 = [UIImage imageNamed:imageName];
image=[[UIImageView alloc]initWithImage:image1];// take image size according to view
[view addSubview:image];
[scrollview addSubview:view];
[view release];
最后定义scrollview
滚动多少:
scrollview.contentSize = CGSizeMake(width,height);
这篇关于滚动视图中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文