1、視圖切換
2、UITabBarController分頁掌握器
留意事項:
詳細步調以下:
//a.初始化一個tabBar掌握器
UITabBarController *tarbarVC = [[UITabBarController alloc] init];
//設置掌握器為Window的根掌握器
self.window.rootViewController = tarbarVC;
//b.創立子掌握器
UIViewController *c1 = [[UIViewController alloc] init];
c1.view.backgroundColor = [UIColor grayColor];
c1.view.backgroundColor=[UIColor greenColor];
c1.tabBarItem.title = @"新聞";
c1.tabBarItem.image = [UIImage imageNamed:@"tab_recent_nor"];
c1.tabBarItem.badgeValue = @"123";
UIViewController *c2 = [[UIViewController alloc] init];
c2.view.backgroundColor = [UIColor brownColor];
c2.tabBarItem.title = @"接洽人";
c2.tabBarItem.image = [UIImage imageNamed:@"tab_buddy_nor"];
UIViewController *c3 = [[UIViewController alloc] init];
c3.tabBarItem.title = @"靜態";
c3.tabBarItem.image = [UIImage imageNamed:@"tab_qworld_nor"];
UIViewController *c4 = [[UIViewController alloc] init];
c4.tabBarItem.title = @"設置";
c4.tabBarItem.image = [UIImage imageNamed:@"tab_me_nor"];
//c.添加子掌握器到ITabBarController中
tarbarVC.viewControllers = @[c1,c2,c3,c4];
//d.設置Window為主窗口並顯示出來
[self.window makeKeyAndVisible];
UITabBarControllerDelegate署理
#pragma mark 該辦法用於掌握TabBarItem能不克不及選中
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController;
轉變UITabBarController以後顯示視圖的辦法
3、UINavigationController導航掌握器
UINavigationItem屬於MVC中的Model,封裝了要顯示在UINavigationBar上的數據:
title: 題目
titleView :題目視圖
leftBarButtonItem :左按鈕
rightBarButtonItem :右按鈕
下一個子視圖左邊前往按鈕leftBarButtonItem的題目優先級:
UINavigationController經常使用的重要辦法:
#pragma mark 壓棧,把掌握器壓入導航掌握器子掌握器棧中
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated;
#pragma mark 出棧,把導航掌握器子掌握器棧的棧頂彈出
- (void)popViewControllerAnimated:(BOOL)animated;
#pragma mark 屢次出棧直到棧頂為指定掌握器
- (void)popToViewController:(UIViewController *)viewController animated:(BOOL)animated;
#pragma mark 屢次出棧直到棧頂為根掌握器
- (void)popToRootViewControllerAnimated:(BOOL)animated;
4、模態窗口
#pragma mark 從下方彈出指定的視圖掌握器,付與模態,即以後視圖封閉前,其他視圖上的內容沒法操作
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion;
#pragma mark 封閉模態窗口,該辦法在模態窗口中挪用
- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion;
【iOS開辟之視圖切換】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!