我正在从 Storyboard 中访问 View 框架的大小。下面是我从 Storyboard访问框架属性的代码。
SmallView *smallView = [self.storyboard instantiateViewControllerWithIdentifier:@"SmallView"];
CGRect frame = smallView.view.frame;
self.containerView.frame = frame;
在 Storyboard中, View 的框架大小为 (200,400)。但是当我从代码访问帧大小时,它总是给出 (320,460)。为什么?在上面的代码中,我从 Storyboard 中获得了小 View 对象,因此 Storyboard 中 View 框架的值应该显示但未显示。始终显示 (320,460)。
为了快速调试,您可以查看下面的源代码。
最佳答案
取消选中检查器中的“Resize View From Nib”复选框。这应该为您提供自由形式 View Controller 的正确尺寸。
关于ios - 从 IOS 中的 Storyboard访问 View 时出现错误的帧值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14520561/