Note that there are some explanatory texts on larger screens.

plurals
  1. POUINavigationBar title and a right button
    primarykey
    data
    text
    <p>I have a navigation controller and in it a view controller:</p> <pre><code>-NavigationController1 --MyViewController </code></pre> <p>And as well I have another navigation controller - NavigationController2. I want to call MyViewController from another view controller - ViewController2, that was pushed into NavigationController2. -NavigationController2 --ViewController2</p> <p>I do it in the following way:</p> <pre><code>@implementation ModifyDicVController - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationItem.rightBarButtonItem = [ [ [UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemAdd target:self action:@selector(add_clicked)] autorelease]; } -(void) add_clicked { [navigationController pushViewController: addWordsVController animated: YES]; } @end </code></pre> <p>And here is the viewWillAppear method of MyViewController(the one that is being called):</p> <pre><code>- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self setTitle: @"My title"]; } </code></pre> <p>I am adding a "done" button to the Navigation Bar when user starts to edit a text field:</p> <pre><code>- (void) textFieldDidBeginEditing: (UITextField *) textField { self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle: NSLocalizedString(@"button: done", @"") style:UIBarButtonItemStyleDone target:self action:@selector(doneEditing)] autorelease]; } </code></pre> <p>The problem is: if I call MyViewController from ViewController2 that was pushed into NavigationController2 and after that I call MyViewController from its own NavigationController1, the title of a navigation bar and a done button is not being added. However viewWillAppear and textFieldDidBeginEditing methods of MyViewController are being called.</p> <p>What is the problem and how can I fix it?</p> <p>Thanks.</p>
    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.
 

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