问题描述
我在iOS 7中的frame-property有一个问题。
我想调整一些UIViews在 viewDidLoad
- 我的 UIViewController
,但如果我这样做 int screenHeight = [[UIScreen mainScreen] bounds] .size.height;
[self.leftSideTableView setFrame:CGRectMake(0,0,320,screenHeight)];
高度设置为我想要的,直到方法结束,每一个其他方法,它是一直在之前!
它有什么问题,还是只是一个编译器或其他错误?
必须将视图大小调整为 -viewDidLayoutSubviews:! p>
将视图框架更改放置到 -viewWillAppear:
或 -viewDidLoad:
将无法工作,因为视图尚未布局!
I have a problem with the frame-property in iOS 7.I wanna resize some UIViews in the viewDidLoad
-method of my UIViewController
, but if I do it like int screenHeight = [[UIScreen mainScreen] bounds].size.height;[self.leftSideTableView setFrame: CGRectMake(0, 0, 320, screenHeight)];
the height is set as I want it till the end of the method, but in every other method it is as is has been before!
What's wrong with it or is it just a bug of the compiler or anything else?
One has to put view resizing into -viewDidLayoutSubviews:
! (documentation)
Placing view frame changes into -viewWillAppear:
or -viewDidLoad:
will not work, because the views are not laying out yet!
这篇关于设置UIView的框架不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!