Created
November 5, 2014 20:17
-
-
Save odrobnik/9c5ec3b54eedf254d916 to your computer and use it in GitHub Desktop.
Workaround for iPhone 6+ horizontal size class bug (when using "present as popover" initial show comes with compact class, only after rotation it is correctly regular)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
// workaround for iPhone 6+ bug | |
if (self.traitCollection.displayScale==3) | |
{ | |
CGSize windowSize = [UIScreen mainScreen].bounds.size; | |
CGSize viewSize = self.view.bounds.size; | |
if (viewSize.width < windowSize.width) | |
{ | |
UITraitCollection *collection = [UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassRegular]; | |
[self _setupForTraitCollection:collection]; | |
return; | |
} | |
} | |
[self _setupForTraitCollection:self.traitCollection]; | |
} | |
- (void)_setupForTraitCollection:(UITraitCollection *)collection | |
{ | |
if (collection.horizontalSizeClass == UIUserInterfaceSizeClassRegular || collection.userInterfaceIdiom == UIUserInterfaceIdiomPad) | |
{ | |
[self.navigationController setNavigationBarHidden:YES]; | |
} | |
else | |
{ | |
[self.navigationController setNavigationBarHidden:NO]; | |
} | |
} | |
- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator | |
{ | |
[self _setupForTraitCollection:newCollection]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment