您的位置:首页 > 移动开发 > IOS开发

iOS中添加逻辑流程(把创建的导航添加到window的rootview)

2016-04-08 00:00 483 查看
#import "AppDelegate.h"
//引入自己新建的"FirstViewController"的头文件
#import "FirstViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

//删掉系统默认的UIViewController,自己新建一个"FirstViewController.h",并且新建一个Window,让"FirstViewController"成为Window的根视图

//创建一个Window
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor redColor];

//让当前的Window成为主窗口
[self.window makeKeyAndVisible];

//设置Window的根视图
FirstViewController *a = [[FirstViewController alloc]init];

//给根视图a上设置一个导航栏
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:a];
self.window.rootViewController = nav;

return YES;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: