Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had the same problem: the pushes working correctly with the titleView item, but the pops letting it disappear after the navigation animation finished. I tried just about every combination, but this is what finally worked:</p> <p>1) In the navigation controller's delegate (which I set to be itself), I inserted:</p> <pre><code>- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated { viewController.navigationItem.titleView = self.myCustomView; } </code></pre> <p>2) Then in each individual view controller (I had 3), I inserted:</p> <pre><code>- (void)viewWillDisappear:(BOOL)animated { self.navigationItem.titleView = nil; } </code></pre> <p>It's really important to use these particular callback methods. It didn't work at all when I used <code>willShowViewController:</code> in the first and/or <code>viewDidDisappear:</code> in the second.</p> <p>The problem with trying to do it in a <code>prepareForSegue:</code> is that it only works in the push direction. You do have access to both controllers though, in the <code>destinationViewController</code> and <code>sourceViewController</code> fields of the <code>segue</code> itself. But to make it work in the other direction, you'd have to put the same code in the <code>unwind segue</code>. I think my solution is probably the simplest (particularly since you're wanting to do it for all the view controllers that your nav controller manages).</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.
    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