在iOS中使用UINavigationController打开另一个视图

时间:2013-10-11 08:19:17

标签: iphone ios

我是iOS开发的新手。我想使用UINavigationController从一个视图移动到另一个视图。请告诉我是否可能,如果可能的话,如何?

2 个答案:

答案 0 :(得分:1)

请尝试以下代码:

SecondVC *detailView = [[SecondVC alloc] initWithNibName:@"SecondVC" bundle:nil];
 [self.navigationController pushViewController:detailView animated:YES];
 [detailView release];

答案 1 :(得分:0)

使用以下方式:

.h文件

#import "SecondViewController.h"

.m文件

 - (IBAction)gotoSecondView:(id) sender
    {
        NSLog(@"I am going to Second View");
        SecondViewController *SecondView = [[SecondViewController  alloc]initWithNibName:@"SecondViewController" bundle:nil];

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

     [SecondView release];
    } 

对于故事板:

SecondViewController* SecondView = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
[self presentModalViewController:SecondView animated:YES];