具体程序如下:
在AppDelegate的加载完成方法中初始化窗口
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//在iOS的较高版本中要求增加rootViewController
self.window.rootViewController = [[UIViewController alloc]init];
// 定义窗口中内容
CGRect screenRect = self.window.bounds;
//.....
//生成视图增加到窗口中
//.....
//其他代码………………………………
//定义窗口的背景
self.window.backgroundColor = [UIColor whiteColor];
//让当前窗口变成主窗口
[self.window makeKeyAndVisible];
return YES;
}