presentModalViewController的使用

1. presentModalViewController和dismissModalViewControllerAnimated配套使用

    [self presentModalViewController:navigation animated:YES];
    [self dismissModalViewControllerAnimated:YES];

用self presentModalViewController:navigation animated的时候:  

    SalaryQueryHome *salaryHome=[[[SalaryQueryHome alloc]init] autorelease];

    UINavigationController *navigation=[[UINavigationController alloc]initWithRootViewController:salaryHome]; 

    navigation.navigationBar.barStyle=UIBarStyleDefault;

    [navigation.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationbar.png"]forBarMetrics:UIBarMetricsDefault];

    

    [self presentModalViewController:navigation animated:YES];

需要自己创建UINavigationController,否则推进去以后没有上边的UINavigationControllerBar;

在那个界面用的presentModalViewController,使用dismiss的时候就返回到最近一次使用presentModalViewController(可能前边好几次用到)那个界面

2.pushViewController和 popViewControllerAnimated配套使用

  [self.navigationController pushViewController:findJobVC animated:NO];

  [self.navigationController popViewControllerAnimated:YES];

  push的时候推到第二个界面自带UINavigationControllerBar,如果推进去了好几个界面,而要返回到开始界面的时候用popToRootViewControllerAnimated

  此处的rootViewController是

    A1FindJobViewController *findJobVC=[[[A1FindJobViewController alloc]init]autorelease];
    UINavigationController *navigation=[[UINavigationController alloc]initWithRootViewController:findJobVC];
  此处定义的这个controller是要返回的rootVireController

 


你可能感兴趣的:(presentModalViewController的使用)