从IOS中的故事板访问视图时错误的帧值 [英] Wrong frame value while accessing the view from storyboard in IOS

查看:68
本文介绍了从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 .


https://dl.dropbox.com/u/90940570/FrameTest.zip


推荐答案

取消选中检查器中的从笔尖调整视图框。这应该为自由形式视图控制器提供正确的大小。

Uncheck the "Resize View From Nib" box in the inspector. That should give you the correct size for a freeform view controller.

这篇关于从IOS中的故事板访问视图时错误的帧值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆