对于iOS,发出“谈话”到UIView和后代的框架和边界元素

时间:2010-08-16 14:32:13

标签: uiview uiscrollview

问候所有人 -

我在为现有UIScrollView分配值时遇到问题。为了响应Orientation,我正在重新定位和调整我在其中包含的ScrollView和UIImageViews的大小。我可以设置UIScrollView的框架:

CGRect wideThumbFrame = CGRectMake(0.0, 530.0, 1024, 190.0); thumbScrollView.frame = wideThumbFrame;

但我似乎无法调整界限:

[thumbScrollView bounds].size.height = 190.0;

编译器说“LValue需要作为左操作数的赋值”。 thumbScrollView不是我的LValue?!?!?我在这里缺少什么?

2 个答案:

答案 0 :(得分:0)

你不能这样做,因为bounds是一个属性,你必须先将它分配给一个局部变量,即

CGRect rect = thumbScrollView.frame;
rect.size.height = 190.0;
thumbScrollView.frame = rect;

答案 1 :(得分:0)

... bounds.size.height是CGRect结构的一部分。 您应该像使用.frame CGRect结构属性一样分配它。 您可以通过将CGRect分配给bounds属性来调整大小。

thumbScrollView.bounds = CGRectMake(thumbScrollView.bounds.origin.x, thumbScrollView.bounds.origin.y, thumbScrollView.bounds.size.width, 190.0);