1
-(IBAction) btnReturn:(id) sender{

    firstView * firstview =[[firstView alloc]initWithNibName:@"firstView" bundle:nil];      
    [self.view pushViewController:firstview animated:NO];
}

with the previsly code I see the first view but the navigation control increment. I wold came bak as was the navigation starting point. Any help?

doxsi
  • 1,002
  • 19
  • 42

3 Answers3

4

pushViewController:animated: will add to the navigation stack; you want popViewControllerAnimated: to go back one view in the stack.

If you want to return to the very first (root) view controller, you want popToRootViewControllerAnimated:.

See: https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html

gregheo
  • 4,182
  • 2
  • 23
  • 22
0

In your above code you are pushing a controller on self.view (firstView, I am considering it as controller as you are creating it using initWithNibName: method, but you should you proper naming conventions to avoid confusions.) But view do not have any such method pushViewController:. Instead you sould use if you really have self (the controller in which you are using this IBAction) in navigation stack.

[self.navigationController pushViewController:firstview animated:NO];

To pop controller from navigation stack, follow what @gregheo suggested.

Ravin
  • 8,544
  • 3
  • 20
  • 19
0

Try using popViewControllerAnimated instead:

- (IBAction)btnReturn:(id)sender
{     
    [self.navigationController popViewControllerAnimated:NO]; // Or Yes if you would like to have an animation.
}
sch
  • 27,436
  • 3
  • 68
  • 83