0

I am trying to change the frame size and position for two UITableViews that are inside a UIViewController that is the rootviewcontroller for UINavigationController.

I want the frame size to change upon a user action. I have everything set up and the following code is executing upon the user's action:

CGRect firstTableFrame = [myTableView frame];
firstTableFrame.size.height = 290;  
[self.myTableView setFrame:firstTableFrame];
NSLog(@"%f",self.myTableView.frame.size.height);
[self.myTableView reloadData];

I can confirm that the NSLog outputs 290. However, nothing on screen changes. I found one answer on here that I thought might solve it (unchecking autolayout) for the .xib file but this results in all sorts of other layout issues with my .xib when I run it.

Is there a way to solve this?

4

2 回答 2

0

我可以通过转到视图控制器的 .xib 文件并在“文件检查器”窗格中取消选中“使用自动布局”来解决此问题。取消选中时,约束被删除,我能够以编程方式调整框架的大小和重新定位。

于 2013-02-27T07:30:17.283 回答
0

这是因为导航控制器有一个视图,其中包含您要添加到其中的视图(您的表视图)。您必须适当地调整该视图的大小

于 2013-02-19T02:35:22.750 回答