开发者

For iOS, issue "talking" to frame and bounds elements of UIView and decendents

开发者 https://www.devze.com 2023-01-11 14:06 出处:网络
Greetings all - I am having an issue assigning a value to an existing UIScrollView. In response to an Orientation change, I am re-orienting and sizing the ScrollView and the UIImageViews I have cont

Greetings all -

I am having an issue assigning a value to an existing UIScrollView. In response to an Orientation change, I am re-orienting and sizing the ScrollView and the UIImageViews I have contained within. I can set the UIScrollView's frame:

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

But I can't seem to adjust ONLY the bounds:

[thumbScrollView bounds].size.height = 190.0开发者_高级运维;

Compiler says "LValue required as left operand of assignment". Is not thumbScrollView my LValue?!?!? What am I missing here?


You can't do that, since bounds is a property, you have to assign it, to a local variable first, ie

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


...bounds.size.height is part of a CGRect structure. You should assign it just like you do with the .frame CGRect structure property. You can adjust the size by assigning a CGRect to the bounds property.

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

精彩评论

暂无评论...
验证码 换一张
取 消