Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I dealt with this same issue by keeping track of the customView's initial frame, then toggling between that and a scaled CGRect of the initial frame in a -setLandscape method on a UIButton subclass. I used the UIButton subclass as navigationItem.titleView and navigationItem.rightBarButtonItem. </p> <p>In UIButton subclass - </p> <pre><code>- (void)setLandscape:(BOOL)value { isLandscape = value; CGFloat navbarPortraitHeight = 44; CGFloat navbarLandscapeHeight = 32; CGRect initialFrame = // your initial frame CGFloat scaleFactor = floorf((navbarLandscapeHeight/navbarPortraitHeight) * 100) / 100; if (isLandscape) { self.frame = CGRectApplyAffineTransform(initialFrame, CGAffineTransformMakeScale(scaleFactor, scaleFactor)); } else { self.frame = initialFrame; } } </code></pre> <p>Then in the InterfaceOrientation delegates I invoked the -setLandscape method on the customViews to change their sizes.</p> <p>In UIViewController - </p> <pre><code>- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [self updateNavbarButtonsToDeviceOrientation];; } - (void)updateNavbarButtonsToDeviceOrientation { ResizeButton *rightButton = (ResizeButton *)self.navigationItem.rightBarButtonItem.customView; ResizeButton *titleView = (ResizeButton *)self.navigationItem.titleView; if (self.interfaceOrientation == UIDeviceOrientationPortrait || self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown) { [rightButton setLandscape:NO]; [titleView setLandscape:NO]; } else { [rightButton setLandscape:YES]; [titleView setLandscape:YES]; } } </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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