iosobjective-cios11uitoolbar

iOS11 UIToolBar Contentview


In iOS 11 buttons and text field are unresponsive being subviews of UIToolBar. Comparing view hierarchy to iOS 10 we see there is a _UIToolBarContentView over all subview of UIToolBar.

For instance, this new layout of the UIToolBar breaks slacktextviewcontroller https://github.com/slackhq/SlackTextViewController/issues/604

Need a solution working in iOS 10/11.


Solution

  • To solve the problem for iOS11 (compatible with lower versions) you only need to make layoutSubview right after UIToolBar was added as a subview to UI hierarchy.

    In this case _UIToolbarContentView lowers to the first subview of UIToolBar, and you can add all your subviews higher as before.

    For example in ObjC,

        UIToolbar *toolbar = [UIToolbar new];
        [self addSubview: toolbar];
        [toolbar layoutIfNeeded];
    
        <here one can add all subviews needed>
    

    The same problem happens with slacktextviewcontroller