Note that there are some explanatory texts on larger screens.

plurals
  1. POresize toolbar in UINavigationController
    primarykey
    data
    text
    <p>I'm adding a series of buttons to a UINavigationBar using:</p> <pre><code> NSArray *items; items = [NSArray arrayWithObjects: fixedSpace, refreshStopBarButtonItem, flexibleSpace, self.backBarButtonItem, flexibleSpace, self.forwardBarButtonItem, flexibleSpace, self.actionBarButtonItem, fixedSpace, nil]; UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, toolbarWidth, 44.0f)]; toolbar.items = items; toolbar.tintColor = [[UIColor whiteColor] colorWithAlphaComponent:1.0]; toolbar.autoresizingMask = UIViewAutoresizingFlexibleHeight; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:toolbar]; </code></pre> <p>All working well.</p> <p>However when I rotate to landscape mode the toolbar within the uinavigationbar doesn't rotate.</p> <p>Adding this code (found on SO) causes the toolbar to resize but not the buttons within it, so they are partially cropped at the bottom and no longer lines up with the toolbar background</p> <pre><code>- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { CGRect navigationToolbarFrame = self.navigationController.navigationBar.frame; CGRect customToolbarFrame = CGRectOffset(navigationToolbarFrame, 0.0, navigationToolbarFrame.size.height); [UIView animateWithDuration:duration animations:^{ //self.toolbar.frame = customToolbarFrame; // FAILS!!! //self.navigationItem.rightBarButtonItem.toolbar.frame = customToolbarFrame; // FAILS!!! }]; } </code></pre> <p>What is the correct way to address the toolbar within the uinavigationbar? Something like...</p> <pre><code>self.toolbar.frame = customToolbarFrame; </code></pre> <p>Or do I have to specify a autoresizemask for the UIBarButtonItems?...</p> <pre><code>self.backBarButtonItem.autoresizingMask = UIViewAutoresizingFlexibleHeight; </code></pre> <p>... trying to do so like this fails</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