user3426161
user3426161

Reputation: 5

go from one UIViewController to another without using navigation (segue) iOS 6

In my program I have UIViewController which has two buttons, one is "signIN" and other is "register". When "Sign IN" button is pressed, it should go to next viewController without using segue and when "register" button is pressed, it should move to next UIViewController by using segue.

Upvotes: 0

Views: 4557

Answers (3)

Mark Molina
Mark Molina

Reputation: 5077

[[self navigationController] pushViewController:yourPushedViewController animated:YES];    

Upvotes: 0

Tom Susel
Tom Susel

Reputation: 3437

Depending on the way you wish to present your view controller you should choose between:

  1. Pushing the new view controller onto the current Navigation controller [self.navigationController pushViewController:someOtherViewController animated:YES];

  2. Present the new view controller modally [self presentModalViewController:someOtherViewController animated:YES completion:nil];

  3. Manually adding the new view controller onto the current view controller: [self addChildViewController:childController]; childController.view.frame = view.bounds; [view addSubview:childController.view]; [childController didMoveToParentViewController:self]; // To remove: [self willMoveToParentViewController:nil]; [self.view removeFromSuperview]; [self removeFromParentViewController];

Upvotes: 2

lootsch
lootsch

Reputation: 1865

Use pushViewController:

- (void)didPressButton:(UIButton *)sender
{
    [self.navigationController pushViewController:nextViewController animated:YES];
}

Upvotes: 0

Related Questions