ios 在 NIB / XIB 文件中设置视图大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23326076/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 00:01:41  来源:igfitidea点击:

Set size of view in NIB / XIB file

iosxcode5nib

提问by Adam

In Xcode 4, there was a never-quite-fixed bug where Xcode prevented you from resizing views (some silly "Design feature") - you had to make sure you set all the topbar/statusbar/navbar/tabbar to "none" before it would unlock the controls.

在 Xcode 4 中,有一个从未完全修复的错误,其中 Xcode 阻止您调整视图大小(一些愚蠢的“设计功能”)-您必须确保在此之前将所有顶部栏/状态栏/导航栏/标签栏设置为“无”它会解锁控件。

XCode 5 appears to have taken this bug ... and extended it!

XCode 5 似乎已经解决了这个错误......并扩展了它!

Now it's completely impossible to edit the size of a UIView in a NIB/XIB file. Nothing I do makes a difference, the dimensions are always readonly. I really, really don't want to write source code (so that our NIB + Storyboards will now always look wrong) to workaround this bug, but I can't find any other way.

现在完全不可能在 NIB/XIB 文件中编辑 UIView 的大小。我所做的没有任何区别,尺寸总是只读的。我真的,真的不想编写源代码(这样我们的 NIB + Storyboards 现在总是看起来错误)来解决这个错误,但我找不到任何其他方法。

Anyone found a workaroind inside Xcode itself?

有人在 Xcode 本身中找到了解决方法吗?

回答by carl_h

In the Attributes inspector, in the Simulated Metrics section, change the size to None. This unlocks the view and you can drag to resize it.

在属性检查器的模拟指标部分,将大小更改为无。这将解锁视图,您可以拖动以调整其大小。

EDIT: As noted in the comments below, in more recent versions of Xcode you must set the attribute to Freeform, not None.

编辑:如下面的评论中所述,在较新版本的 Xcode 中,您必须将该属性设置为Freeform,而不是None

回答by Kevin ABRIOUX

There is the solution for XCode 9.0

XCode 9.0的解决方案

Select your view and set simulated Metrics as this :

选择您的视图并将模拟指标设置为:

enter image description here

在此处输入图片说明

After this, you can edit your view's size :

在此之后,您可以编辑视图的大小:

enter image description here

在此处输入图片说明

DEPRECATED :

已弃用:

There is the solution for XCode 8.1

XCode 8.1的解决方案

Select your view and set simulated Metrics as this :

选择您的视图并将模拟指标设置为:

enter image description here

在此处输入图片说明

After this, you can edit your view's size :

在此之后,您可以编辑视图的大小:

enter image description here

在此处输入图片说明

回答by Vlad Papko

Such settings:
XIB settings

这样的设置:
XIB 设置

makes me possible to change viewsize:
XIB settings

让我可以改变view大小:
XIB 设置

Xcode version: 5.1 (5B130a)

Xcode 版本:5.1 (5B130a)