多層導航欄下的登錄註銷架構

1.APPDelegate建立一個Nav,做爲主Nav:app

//.h

@property (strong, nonatomic) LoginController *login_ctr;

@property (strong, nonatomic) UINavigationController *login_nav;

//.m

self.login_ctr = [[LoginController alloc] init];

self.login_nav = [[UINavigationController alloc] initWithRootViewController:self.login_ctr];

self.window.rootViewController = self.login_nav;

2.Login界面建立tab控制器,並添加各個子Nav:atom

HomeController *home_ctr = [[HomeController alloc] init];

home_ctr.title = @"首頁";

UINavigationController *home_nav = [[UINavigationController alloc] initWithRootViewController:home_ctr];

DeviceController *device_ctr = [[DeviceController alloc] init];

device_ctr.title = @"設備列表";

UINavigationController *device_nav = [[UINavigationController alloc] initWithRootViewController:device_ctr];

 

UITabBarController *rootTabbarCtr  = [[UITabBarController alloc] init];

NSArray *nav_views = @[home_nav,device_nav];

[rootTabbarCtr setViewControllers:nav_views];

 

[self.navigationController pushViewController:rootTabbarCtr animated:YES];

 

3.在須要返回最上層Login界面時調用:spa

AppDelegate *app = (AppDelegate *)[[UIApplication  sharedApplication] delegate];

[app.login_nav popToRootViewControllerAnimated:YES];
相關文章
相關標籤/搜索