Hi fellow developers,
I'm suprised that I didn't find any information on that particular use case for iOS 8. Let me explain, I have a navigation controller stack, the first view has it's navigationBar hidden, when the user clicks on a cell a new view is pushed and I need the navigation bar shown on this view to go back (obviously). On iOS 7 it was just a matter of adding this line in viewWillAppear :
[self.navigationController setNavigationBarHidden:NO animated:YES];
And it works like a charm. But as of iOS 8 I'm struggling to have the same behavior. For now I managed to do the same by using :
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
- (void)viewDidLoad {
[super viewDidLoad];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
self.automaticallyAdjustsScrollViewInsets = NO;
self.edgesForExtendedLayout = UIRectEdgeNone;
self.collectionView.contentInset = UIEdgeInsetsMake(self.navigationController.navigationBar.frame.size.height, 0, 0, 0);
} }
And changing the contentInset of my collectionsView / tableviews whatever I need to display. It'll work, but it's a real pain in the * (sometimes the content inset isn't necessary if the user comes from a new viewcontroller).
For context the project was first developed to handle iOS 6 and 7, so no storyboard, all is done programmatically. I ported the app to a more modern codebase and made it universal.
Am I missing something ? Is there a better way to handle that in iOS 7/8 ?