I have 2 UIViewControllers, both connected to the same UINavigationController. I want to hide the navigation bar for the first controller but show it for the second controller. For this behaviour I use this code:
override func viewWillAppear(animated: Bool) {
self.navigationController?.setNavigationBarHidden(true, animated: false)
}
override func viewWillDisappear(animated: Bool) {
self.navigationController?.setNavigationBarHidden(false, animated: false)
}
This causes the second controller's UICollectionView to move down after around 0.5 second and the black area appears. The gray area is the collection view and its top constraint is linked to the view containing the UISegmentedControl.
The message in the console :
the behavior of the UICollectionViewFlowLayout is not defined because:
2016-03-15 17:26:58.829 Goku[56059:15539317] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2016-03-15 17:26:58.830 Goku[56059:15539317] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7ffa28d49840>, and it is attached to <UICollectionView: 0x7ffa2a971000; frame = (0 119; 375 548); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x7ffa28d5f950>; layer = <CALayer: 0x7ffa28d6e120>; contentOffset: {375, -64}; contentSize: {1125, 548}> collection view layout: <UICollectionViewFlowLayout: 0x7ffa28d49840>.
2016-03-15 17:26:58.830 Goku[56059:15539317] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
This message only appears if I hide/show the navigation bar, autolayout works just fine if I don't.
Setting the translucency property of the UINavigationBar to false fixes the problem for some reason, is there a way to fix this problem without changing the translucency property?

