iPhone X how to handle View Controller inputAccessoryView?

前端 未结 15 2658
长情又很酷
长情又很酷 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:20

    In the case you already have a custom view loaded via nib file.

    Add a convenience constructor like this:

    convenience init() {
        self.init(frame: .zero)
        autoresizingMask = .flexibleHeight
    }
    

    and override intrinsicContentSize:

    override var intrinsicContentSize: CGSize {
        return .zero
    }
    

    In the nib set the first bottom constraint (of views that should stay above the safe area) to safeArea and the second one to superview with lower priority so it can be satisfied on older iOS.

提交回复
热议问题