iOS 11 inputAccessoryView broken

后端 未结 2 460
眼角桃花
眼角桃花 2021-01-28 05:06

I have the following set up for my UIToolBar / Accessory View on a view controller

@IBOutlet var inputFieldView: UIToolbar!
override var canBecomeFirstResponder:         


        
相关标签:
2条回答
  • 2021-01-28 05:47

    This is a known bug on iOS 11. UIToolbar subviews don't get the touch events because some internal views to the toolbar aren't properly setup.

    The current workaround is to call toolBar.layoutIfNeeded() right before adding subviews.

    In your case:

    inputFieldView.layoutIfNeeded()
    

    Hopefully this will get fixed on the next major version.

    0 讨论(0)
  • 2021-01-28 05:54

    Solved it. It looks like UIToolbar's just are not working correctly in iOS 11.

    Changed it to an UIView and removed

    self.inputFieldView.isTranslucent = false
    self.inputFieldView.setShadowImage(UIImage(), forToolbarPosition: .any)
    self.inputFieldView.setBackgroundImage(UIImage(), forToolbarPosition: .any, barMetrics: .default)
    

    got it working (and changed it to a UIView from UIToolbar in the xib as well.)

    0 讨论(0)
提交回复
热议问题