Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you push view controller into navigation controller, it's backBarButtonItem will be set up for back to previous view controller, not leftBarButtonItem. If you set up leftBarButtonItem, the backBarButtonItem will be hide and the same place will be replaced by the leftBarButtonItem. </p> <p>And your code doesn't set leftBarButtonItem at all, so of course it is nil.</p> <p>EDIT: My test codes. I checked the backButtonItem and leftBarButtonItem by following codes, and they are nil. You are right. But when I touched the back button to previous view, its color did change, so it was highlighted. And it worked well back to previous view controller. So I think your code is wrong at some else place, it makes the back button inactive. </p> <p>Listing 1, RootViewController class</p> <pre><code>// RootViewController.h #import &lt;UIKit/UIKit.h&gt; @interface RootViewController : UIViewController { } @end // RootViewController.m #import "RootViewController.h" #import "MyViewController.h" @implementation RootViewController - (void)viewDidLoad { [super viewDidLoad]; self.title = @"RootView"; MyViewController *childView = [[[MyViewController alloc] init] autorelease]; UINavigationController *navCtrl = [[[UINavigationController alloc] initWithRootViewController:childView] autorelease]; [self.navigationController presentModalViewController:navCtrl animated:YES]; } @end </code></pre> <p>Listing 2, MyViewController</p> <pre><code>// MyViewController.h #import &lt;UIKit/UIKit.h&gt; @interface MyViewController : UIViewController { } @end // MyViewController.m #import "MyViewController.h" #import "MyAnotherViewController.h" @implementation MyViewController // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; self.title = @"MyView"; NSLog(@"%s backBarButtonItem:%@ leftBarButtonItem:%@",__FUNCTION__ ,self.navigationItem.backBarButtonItem, self.navigationItem.leftBarButtonItem); MyAnotherViewController *childView = [[[MyAnotherViewController alloc] init] autorelease]; [self.navigationController pushViewController:childView animated:YES]; } @end </code></pre> <p>Listing 3, MyAnotherViewController</p> <pre><code>// MyAnotherViewController.h #import &lt;UIKit/UIKit.h&gt; @interface MyAnotherViewController : UIViewController { } @end // MyAnotherViewController.m #import "MyAnotherViewController.h" @implementation MyAnotherViewController - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Another View"; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload