Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open new view controller after click button?

I added one ViewController to my project and created one class. After I bind this class to my ViewController.

In another controller I have method:

- (IBAction)login:(id)sender { // How here I can do redirect to controllerViewController }

like image 840
Balabama Avatar asked Oct 19 '25 15:10

Balabama


2 Answers

There are two ways to push view controllers in the application.

1) by Segue

2) By View controller identifier

1) By Segue :

[self performSegueWithIdentifier:"SegueIdentifier" sender:self];

2) By View controller identifier :

Yourclassname *gotoYourClass = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerIdentifier"];

[self.navigationController pushViewController:gotoYourClass animated:YES];
like image 53
Premal Khetani Avatar answered Oct 21 '25 06:10

Premal Khetani


- (IBAction)login:(id)sender {
 ViewController *vc = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
 [self presentViewController:vc animated:YES completion:nil]; }
like image 44
Sanket_B Avatar answered Oct 21 '25 07:10

Sanket_B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!