一、導航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];
}
代碼例子一二的如下: