How do I show the keyboard with a view above it?

前端 未结 2 1304
自闭症患者
自闭症患者 2021-01-16 15:15

When a user taps on a button, I\'d like the keyboard to pop up (which is easy), but I want a view that goes up along with it (sticking to the top of the keyboard). This vie

2条回答
  •  忘掉有多难
    2021-01-16 15:35

    UITextFields have a property called inputAccessoryView

    - Apple Documentation

    - Relevant Stack Overflow Answer

    This will pin whatever view you assign as that textfield's inputAccessoryView to the top of the keyboard.

    Something important from the answer in that link to remember:

    Note that the view you use should neither be in the view hierarchy elsewhere, nor should you add it to some superview, this is done for you.

提交回复
热议问题