window
1.将main删掉
2.新建一个ViewController.xlb(File中新建一个View)
将此视图的File’s Owner的父类设置为ViewController
按住comment,将File’s Owner拖向View,选择View
3.在AppDelegate.m中导入:
import “ViewController.h”
4.设置第一个视图
self.window=[[UIWindow alloc] initWithFrame: [[UIScreen mainScreen]bounds]]; ViewController *theFirstView =[[ViewController alloc] init]; [self.window setRootViewController:theFirstView];//UIWindows有一个根视图控制器,负责配置窗体显示时第一个显示的视图
[self.window makeKeyAndVisible];//让窗口成为主窗口,并且显示出来。有这个方法,才能把信息显示到屏幕上
initWithFrame:需要传递CGRect类型的参数
CGRect
解释:在屏幕上定义一个矩形
struct CGRect
{
CGPoint origin;
CGSize size;
};
typedef struct CGRect CGRect;
CGRect bound = [[UIScreen mainScreen]bounds];//返回带状态的Rect(信号时间横条)
CGRect frame = [[UIScreen mainScreen]applicationFrame];//返回不带状态的Rect(显示为一个黑条)
[UIScreen mainScreen]
运行程序设备的屏幕信息对象