Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create back button in navigation bar

Tags:

I have 2 page. first is tableView and second is view when I to click on any cell go on to next page (view) in way modal segue. I want add back button in next page of navigation bar . this is my code in view page : ViewController.m

- (void)viewDidLoad {     [super viewDidLoad];     self.lable.text = obji.Name;     self.lable2.text = obji.Descript;      UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(Back)];     self.navigationItem.leftBarButtonItem = backButton; }  - (IBAction)Back {     //I dont know that how return pervious page } 
like image 475
janatan Avatar asked Apr 17 '13 10:04

janatan


People also ask

How do I add back button to navigation bar storyboard?

Storyboard. You can also set this in the Storyboard. Select UINavigationBar and select the Attributes Inspector tab. Then you can change those two images under Back and Back Mask attributes.

How do I add a button to my navigation bar?

Example ExplainedUse any element to open the dropdown menu, e.g. a <button>, <a> or <p> element. Use a container element (like <div>) to create the dropdown menu and add the dropdown links inside it. Wrap a <div> element around the button and the <div> to position the dropdown menu correctly with CSS.


1 Answers

As you said in your comment you use a modal controller

Add the following in viewWillappear

     UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style: UIBarButtonItemStyleBordered target:self action:@selector(Back)];      self.navigationItem.leftBarButtonItem = backButton; 

And in

- (IBAction)Back   {     [self dismissViewControllerAnimated:YES completion:nil]; // ios 6   } 
like image 175
Lochana Ragupathy Avatar answered Oct 12 '22 09:10

Lochana Ragupathy