Note that there are some explanatory texts on larger screens.

plurals
  1. POModify the More button on the Navigation bar of a tab displayed from a UITabBarController's More tab
    primarykey
    data
    text
    <p>I have an app with a <strong>UITabBarController</strong> that has more than five tabs.</p> <p><img src="https://i.stack.imgur.com/dWM09.png" alt="enter image description here"></p> <p>When I press the <strong>More</strong> tab, I go to the <strong>moreNavigationController</strong> which is a <strong>UINavigationController</strong>.</p> <p><img src="https://i.stack.imgur.com/fyJZ2.png" alt="enter image description here"></p> <p>As you can see, I have figured out how to style the <strong>Title</strong>, <strong>Tint</strong>, <strong>Table color</strong>, and the <strong>Edit</strong> button on the <strong>More</strong> screen, as well as the <strong>Configure</strong> screen from pressing the <strong>Edit</strong> button.</p> <p>What I have not been able to figure out is how to style the back button, titled <strong>More</strong>, when I select an item in the table.</p> <p><img src="https://i.stack.imgur.com/ExzM9.png" alt="enter image description here"></p> <p>Each tab has it's own class, <strong>GRWTabSettingsViewController</strong> for example, which inherits from <strong>GRWViewController</strong>, which provides common functionality for all tabs, which then inherits from <strong>UIViewController</strong>.</p> <p>When on the <strong>Settings</strong> screen (or any other tab), I am trying to edit the <strong>More</strong> back button.</p> <pre><code>- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [(UIBarButtonItem *)[(UINavigationItem *)[(UINavigationBar *)[(UINavigationController *)[self navigationController] navigationBar] topItem] leftBarButtonItem] setTintColor:[UIColor darkGrayColor]]; [self.navigationController.navigationBar.topItem.leftBarButtonItem setTintColor:[UIColor darkGrayColor]]; } </code></pre> <p>However, this <strong>navigationController</strong> is clearly the <strong>parent</strong> since these changes get applied to the <strong>More</strong> screen and not the <strong>Settings</strong> screen.</p> <p>What am I misunderstanding and how would I modify the buttons displayed on the navigation bar of the screen I am viewing?</p> <p><strong>=== SOLUTION ===</strong></p> <p><img src="https://i.stack.imgur.com/fZHtv.png" alt="enter image description here"></p> <pre><code>- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // use backBarButtonItem not leftBarButtonItem //[(UIBarButtonItem *)[(UINavigationItem *)[(UINavigationBar *)[(UINavigationController *)[self navigationController] navigationBar] topItem] leftBarButtonItem] setTintColor:[UIColor darkGrayColor]]; //[self.navigationController.navigationBar.topItem.leftBarButtonItem setTintColor:[UIColor darkGrayColor]]; UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:self.navigationController.navigationBar.topItem.title style:UIBarButtonItemStylePlain target:nil action:nil]; [backButton setTintColor:[UIColor darkGrayColor]]; self.navigationController.navigationBar.topItem.backBarButtonItem = backButton; // these do not work //[self.navigationController.navigationBar.topItem.backBarButtonItem setTintColor:[UIColor darkGrayColor]]; //[backButton setTintColor:[UIColor darkGrayColor]]; } </code></pre> <p>Did take me a while to figure out that I can not format the button through <strong>self</strong>, or format the button after the assignment to <strong>self</strong>.</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.
 

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