2012-07-24 53 views
0

我在ScrollView中有一个ImageView,并在某个时间调整了ScrollView的大小。问题是,ImageView调整为与ScrollView相同的大小,但我希望它保持原始图像大小。Scrollview中的图像大小调整

我在做什么,这是:

scrollView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); // fullscreen scrollview 
[scrollView setContentMode:UIViewContentModeTopLeft]; //i want the content to be on the top left, thats correct right? 
[scrollView setContentSize:CGSizeMake(imageInScrollView.frame.size.width, imageInScrollView.frame.size.height)]; // now im setting the size of the content, which is like 200x200 but it shows in fullscreen 

请阅读我旁边的代码中的注释,谢谢!

回答

0

您需要更改autoresizingMaskUIView

autoresizingMask
一个整数位掩码,决定接收机如何调整自身大小 当它的父的边界变化。

你可以做到这一点是这样的:

[myImageView setAutoresizingMask:UIViewAutoresizingNone]; 
+0

加入这一行我的代码,但它什么也没做 – oybcs 2012-07-24 09:19:35

0

的的UIScrollViewcontentSize不影响拉丝,它只是用于滚动目的(即定义了一个矩形内,用户可以滚动)。

请提供有关imageInScrollView,它是包含在UIImageView更多信息特别检查其frame属性是正确的,你想要什么,并检查其autoresizingMask:你可能要像

imageView.autoresizingMask = UIViewAutoresizingNone; 

最后,您应该做的:

[scrollView setContentSize:imageView.frame.size]; 

,因为这是更简单的

+0

嗨,我检查了两者的框架。 imageInScrollView(实际上是一个ImageView)和滚动视图350.000000,335.000000 // imageview - 540.000000,576.000000 //滚动视图..并且它没有用于放置autoresizingnone – oybcs 2012-07-24 09:17:58

+0

什么是imageView.image.size? – Olotiar 2012-07-24 09:40:40

+0

对不起,image.size是350x335,而imageView的框架是:540.000000,516.857178 – oybcs 2012-07-24 09:47:52