iPhone X how to handle View Controller inputAccessoryView?

前端 未结 15 2656
长情又很酷
长情又很酷 2020-11-30 00:43

I have a messaging app that has the typical UI design of a text field at the bottom of a full screen table view. I am setting that text field to be the view controller\'s

15条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 01:12

    Until safe are insets are guided by iOS automatically, simple workaround would be to wrap your accessory in container view and set bottom space constraint between accesory view and container view to match safe area insets of window.

    Note: Of course this workaround can double your accessory view spacing from bottom when iOS update fixes bottom spacing for accessory views.

    E.g.

    - (void) didMoveToWindow {
        [super didMoveToWindow];
        if (@available(iOS 11.0, *)) {
            self.bottomSpaceConstraint.constant = self.window.safeAreaInsets.bottom;
        }
    }
    

提交回复
热议问题