关于iOS uinavigationcontroller及Uitabbarcontroller知识的梳理

一、导航UINavigationController

导航到一个controller:

 [navigateController pushViewController:loginView animated:YES];

返回到上页的代码:

 [self.navigationController popViewControllerAnimated:YES];

返回到根的代码:

 [self.navigationController popToRootViewControllerAnimated:<#(BOOL)#>]

返回固定view的代码:

   [self.navigationController popToViewController:<#(UIViewController *)#> animated:<#(BOOL)#>:<#(BOOL)#>]

示例代码:

 代码例子一

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

{

    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

    // Override point for customization after application launch.

    LoginViewController  *loginView=[[LoginViewController alloc] init];

    loginView.title=@"用户登陆";

    UINavigationController* navigateController=[[UINavigationController alloc]init];

    [navigateController pushViewController:loginView animated:YES];

    [self.window addSubview:navigateController.view];

    self.window.backgroundColor = [UIColor whiteColor];

    [self.window makeKeyAndVisible];

    return YES;


}


二、Uitabbarcontroller知识的梳理

代码例子二

-(void) onLogin:(id)sender

{

   

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

    InfoViewController* info=[[InfoViewController alloc]init];

    info.title=@"话费查询";

    UINavigationController* infoNav=[[UINavigationController alloc]init];

    [infoNav pushViewController:info animated:YES];

    

    

    UINavigationController* indexNav=[[UINavigationController alloc]init];

    indexViewController* indexController=[[indexViewController alloc]init];

    indexController.title=@"拜佛系统";

    [indexNav pushViewController:indexController animated:YES];

    

    tabController.viewControllers=[NSArray arrayWithObjects:indexNav,infoNav, nil];

    [self presentModalViewController:tabController animated:YES];

            

}


代码例子一二的效果图如下:

关于iOS uinavigationcontroller及Uitabbarcontroller知识的梳理_第1张图片关于iOS uinavigationcontroller及Uitabbarcontroller知识的梳理_第2张图片



你可能感兴趣的:(关于iOS uinavigationcontroller及Uitabbarcontroller知识的梳理)