Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to navigate from one view controller to another view controller on button click?

I am new to iOS Application development, please help me how can I go from one view controller to another view controller on button click?

like image 389
user1355217 Avatar asked Apr 25 '12 04:04

user1355217


2 Answers

Follow the below step,let the button selector is

[button addTarget:select action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside]; and implement the selector as

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

and also make sure viewController has NavigationController embedded within it and replace UIViewController with the Controller you wish to push.

like image 108
sKhan Avatar answered Oct 03 '22 02:10

sKhan


Use this code in your Objective-C function for navigation -

DashboardViewController *dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DashboardView"];
[dvc setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:dvc animated:YES completion:nil];
like image 45
Mohammad Kamran Usmani Avatar answered Oct 03 '22 03:10

Mohammad Kamran Usmani