从IOS中的故事板访问视图时错误的帧值 [英] Wrong frame value while accessing the view from storyboard in IOS
问题描述
我从故事板访问视图的大小。下面是我从storyboard访问frame属性的代码。
I am accessing the size of the frame of view from storyboard. Below is my code for accessing frame property from storyboard.
SmallView *smallView = [self.storyboard instantiateViewControllerWithIdentifier:@"SmallView"];
CGRect frame = smallView.view.frame;
self.containerView.frame = frame;
在故事板中,视图的帧大小为(200,400)。但是当我从代码中访问帧大小时,它总是给出(320,460)。为什么?在上面的代码中,我从故事板中得到了一个小视图对象,所以应该显示的故事板中视图框架的价值是什么,但它没有显示。总是显示(320,460)。
In story board the frame size of the view is (200,400). But when I am accessing the frame size from the code it's always giving (320,460).Why? In the above code I got small view object from storyboard so what will be the value of view's frame in story board that should be shown but it's not showing.Always it's showing (320,460).
为了快速调试,您可以查看以下源代码。
For quick debugging you can check the below source code .
推荐答案
取消选中检查器中的从笔尖调整视图框。这应该为自由形式视图控制器提供正确的大小。
Uncheck the "Resize View From Nib" box in the inspector. That should give you the correct size for a freeform view controller.
这篇关于从IOS中的故事板访问视图时错误的帧值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!