如何在UIViewController上使用PushViewController?

Eag*_*ver 1 iphone uitableview uinavigationcontroller ipad

我有一个UIViewController,我有一个导航栏和一个表,现在我想从这个视图导航到选择表行的另一个视图.

我怎样才能做到这一点?

Par*_*att 6

首先,通过右键单击文件和组部分并单击" 新建文件 "选项并将其命名为SecondViewController,将新的UIViewController添加到您的应用程序中.

在创建SecondViewController时,确保通过选择" With XIB for user interface "选项添加XIB

假设您想按下按钮上的新视图,然后向FirstViewController添加一个按钮,并在其按钮的TouchUpInside事件中添加以下代码:

 SecondViewController *secondView=[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
 [self.navigationController pushViewController:secondView animated:YES];
 [secondView release];
Run Code Online (Sandbox Code Playgroud)

如果您使用ARC然后删除[secondView release];.

如果您需要更多帮助,请告诉我.

希望这可以帮助.