iPhone X UINavigationController Toolbar Is Not Placed on Top of Tab Bar

Has anyone had problems with the UINavigationController's toolbar on the iPhone X (in the Simulator) when part of a view controller that's in a tab bar controller? I have a UIViewController that I add to a UITabBarController. In the UIViewController I set navigationController.toolbarHidden to NO. The toolbar appears down near the bottom on the iPhone X but there's a gap between the toolbar and the tab bar. The toolbar should be placed on top of the tab bar with no gap.

Replies

Maybe you should try UINavigationBarDelegate, confirm that:


#pragma mark - UINavigationBarDelegate
- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
    return UIBarPositionTopAttached;
}


Assign toobar delegate with view controller you in

I think it's just a bug. The method you mention is for custom toolbars. I'm using the toolbar managed by the navigation controller.


/ Implement this method on your manual bar delegate when not managed by a UIKit controller.
UINavigationBar and UISearchBar default to UIBarPositionTop, UIToolbar defaults to UIBarPositionBottom.
This message will be sent when the bar moves to a window.
*/
- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar;


@property(nullable, nonatomic, weak) id<UIToolbarDelegate> delegate NS_AVAILABLE_IOS(7_0); // You may not set the delegate when the toolbar is managed by a UINavigationController.

I've noted the same issue too. It may be interesting to point out that even when using IB the toolbar "floats" above the tab bar (both simple native controls in the view I'm talking about, nothing fancy/tricky being done to their layout) so, at least for the moment, I'm assuming this is just a bug in iOS 11.0 GM.

in xcode 9 and swift 4 the follwing did not help me

func position(for bar: UIBarPositioning) -> UIBarPosition {

return .topAttached

}

I have the same problem. I added a bug report. https://bugreport.apple.com/web/?problemID=34809930

Affects my app as well, and seems to clearly be a bug with iOS. Here's a Stack Overflow link: https://stackoverflow.com/questions/46205703/ios-11-iphone-x-uinavigationbars-toolbar-spacing-incorrect-when-embedded-in

I can't access the bug report, do you have any update on this issue?

I also see this issue. Hopefully it gets resolved soon.

Should be fixed with iOS 11.2