Rishabh
Rishabh

Reputation: 62

how will back button work in iPhone whithout using navigation bar?

#

I have two view named FirstView and Second View. Now I have one button in SecondView. If i click this button then i want to move FirstView. What is the code for it?

#

Upvotes: 1

Views: 223

Answers (2)

TheEye
TheEye

Reputation: 9346

You could still use a UINavigationController, but hiding the navigation bar with calling

[self.navigationController setNavigationBarHidden:true animated:false];

in the second view's viewDidLoad method.

Then just show the second view by pushing it on the navigation stack in the first view:

[self.navigationController pushViewController:secondViewController animated:true];

and pop it from the stack when your button is pressed in the second view:

[self.navigationController popViewControllerAnimated:true];

Upvotes: 2

Manali
Manali

Reputation: 573

Add SecondView as subview of FirstView. To go back, in the action method of back button, you could remove it from parent view. In firstView :

[self addSubview:secondView];

In secondView :

- (IBAction)backButtonClicked:(id)sender {
   [self removeFromSuperview];
  }

Upvotes: 0

Related Questions