如何从一个视图控制器导航到按钮,单击另一个视图控制器?(How to navigate from o

2019-06-23 22:52发布

我是新来的iOS应用开发,请帮助我,我如何从一个去view controller到另一个view controller上的按钮点击?

Answer 1:

按照下面的步骤,让按钮选择是

[button addTarget:select action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside]; 贯彻选择为

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

并且确保了的viewController嵌入NavigationController内,并与要推控制器更换的UIViewController。



Answer 2:

试试这个:

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


Answer 3:

使用此代码在您的Objective-C功能导航-

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


Answer 4:

你可以使用任何的方法 -

  1. pushViewController:动画: - 推动在导航堆栈视图

  2. presentModalViewController:NC动画: - 要模态呈现视图。



Answer 5:

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

希望,这将有助于you..enjoy



Answer 6:

// SAViewController将是你destiation视图

在当前视图//进口SAViewController.h文件

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


Answer 7:

试试这个代码:

- (IBAction)btnJoin:(id)sender {

   SecondViewController *ViewController2 = [self.storyboardinstantiateViewControllerWithIdentifier:@"SecondViewController"];
   [self.navigationController pushViewController: ViewController2 animated:YES];

}


文章来源: How to navigate from one view controller to another view controller on button click?