xcode 为什么我不能再调整视图的大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16653192/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
why can't I resize my views anymore?
提问by Dan Morrow
I'm using Xcode 4.6.2, and am having trouble resizing my views.
我使用的是 Xcode 4.6.2,但在调整视图大小时遇到问题。
For instance, I just created a new Storyboard, and dropped one regular UIView on top of another. I went to to change it's top, by grabbing the handle, and the whole top line became red, and would not move.
例如,我刚刚创建了一个新的 Storyboard,并将一个常规 UIView 放在另一个之上。我去换它的顶部,抓住把手,整个顶部线变成红色,动弹不得。
Now, I can force it to move by holding down the option key (or is it the command key), but I used to be able to resize views pretty easily it Xcode. I'm wondering, is Auto Layout causing me these headaches? Or is it some setting that I'm missing? I just want to resize my newly-dropped view, by dragging the handles, but can't.
现在,我可以通过按住选项键(或者它是命令键)来强制它移动,但我曾经能够很容易地在 Xcode 中调整视图的大小。我想知道,自动布局是否让我头疼?还是我缺少某些设置?我只想通过拖动手柄来调整我新放置的视图的大小,但不能。
回答by James
Yes, I think it is autolayout. In building my views when I have seen the behavior you describe it is because I'm resizing a view that has fairly rigid constraints between its edges and other views. I usually get around it by first updating my constraints to something less restrictive (by deleting or lowering the priority) and then reviewing the constraints once I have resized it.
是的,我认为这是自动布局。在我看到您描述的行为时构建我的视图是因为我正在调整一个视图的大小,该视图的边缘和其他视图之间具有相当严格的约束。我通常通过首先将我的约束更新为限制较少的内容(通过删除或降低优先级),然后在调整其大小后查看约束来解决这个问题。
You may also have success unchecking the options in the When Resizing Views Apply Constraints To...
menu. In the storyboard editor it is in buttons on the lower right and looks like two rectangles (windows) with one smaller than the other.
您也可以成功取消选中When Resizing Views Apply Constraints To...
菜单中的选项。在故事板编辑器中,它位于右下方的按钮中,看起来像两个矩形(窗口),一个比另一个小。
回答by S1LENT WARRIOR
The above mentioned solution didn't work for me.
上面提到的解决方案对我不起作用。
What i did to resolve this issue was that i explicitly set the frame of the view in viewDidLoad
.
我为解决这个问题所做的是在viewDidLoad
.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.frame = CGRectMake(0.0, 0.0, 280.0, 170.0); // explicitly set your view's frame
}