在objective-c中设置iOS大小的窗口?

时间:2017-07-17 04:19:37

标签: ios objective-c uiview rootviewcontroller

enter image description here

我试图找出设置窗口边界的位置。目前视图不会填满整个屏幕。

我刚刚开始了解iOS的UI设计。我没有在app委托中设置rootViewController,也没有实例化我的视图嵌入的导航控制器。

我在appDelegate的didFinishLaunching方法中尝试使用下面的代码。

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
self.rootVC= [[LaunchViewController alloc] init];
self.window.rootViewController =  self.rootVC;

[self.window makeKeyAndVisible];
return YES;

有人可以帮助我理解为什么这会显示我的观点。如果我删除添加的编码并保留返回YES,我的视图会加载,但就像我发布的图片一样。

enter image description here

编辑:

我需要标签和表格视图来扩展整个屏幕,而不仅仅是在左上角。我不知道为什么它会像这样加载而不是整个屏幕..请帮助

1 个答案:

答案 0 :(得分:2)

这不是关于窗口大小的问题。这与您放入窗口的组件的大小有关。

如果您使用的是故事板,则必须对视图进行一些限制。

您可以查看此链接:

https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/WorkingwithConstraintsinInterfaceBuidler.html