Make UITextView parent be its own inputAccessoryView

后端 未结 3 1456
时光取名叫无心
时光取名叫无心 2021-02-09 16:29

I\'m trying to achieve a similar keyboard interaction that Messages has in iOS 7. I have a UIView which contains a UITextView, and when the user select

3条回答
  •  执笔经年
    2021-02-09 16:43

    A much easier solution is to make your input field the input accessory view of your view controller:

    - (BOOL)canBecomeFirstResponder
    {
        return YES;
    }
    
    - (UIView *)inputAccessoryView
    {
        return self.yourInputField;
    }
    

    The view will be on screen at the bottom of the screen and when it becomes first responder in response to a user tapping it, the keyboard will be presented. The view will be animated such that it remains immediately above the keyboard.

提交回复
热议问题