如何从一个视图控制器导航到另一个视图控制器button点击?

我是新的iOS应用程序开发,请帮我怎么从一个view controller到另一个view controllerbutton点击?

按照下面的步骤,让buttonselect器

[button addTarget:select action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside]; 并执行select器

 -(void)buttonClick{ UIViewController *controler = [[UIViewController alloc] init]; [self.navigationController pushViewController:controler animated:YES];} 

并确保viewController内嵌有NavigationController,并将UIViewControllerreplace为您希望推送的控制器。

尝试这个:

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

在您的Objective-C函数中使用此代码进行导航 –

 DashboardViewController *dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DashboardView"]; [dvc setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; [self presentViewController:dvc animated:YES completion:nil]; 

你可以使用任何方法 –

  1. pushViewController:animation: – 在导航堆栈上推视图

  2. presentModalViewController:NCanimation: – 以模态呈现视图。

 YourSecondViewcontroller *temp = [[YourSecondViewcontroller alloc]initWithNibName:@"YourSecondViewcontroller" bundle:nil]; [self.navigationController pushViewController:temp animated:YES]; 

//要么

 [self presentModalViewController:temp animated:YES]; 

Visit this reference for tutorial and working demo code

希望这会帮助你

// SAViewController将是你的目标视图

//在当前视图中导入SAViewController.h文件

 SAViewController *admin = [[SAViewController alloc]initWithNibName:@"SAViewController" bundle:nil]; [self presentModalViewController:admin animated:YES]; [admin release];