How to hide inputAccessoryView without dismissing keyboard

后端 未结 11 1184
挽巷
挽巷 2021-01-02 02:49

I am using a toolbar in the inputAccessoryView property of a textView. When the keyboard shows, it displays the toolbar as expected. When the device is rotated I want to rem

11条回答
  •  别那么骄傲
    2021-01-02 03:14

    Based on Eric Appel's answer:

    myTextView.inputAccessoryView = nil;
    [myTextView reloadInputViews];
    hideInputAccessoryView = YES;
    

    Further modify:

    - (BOOL)canBecomeFirstResponder
    {
        BOOL showInputAccessoryView = YES;
    
        if (hideInputAccessoryView)
            showInputAccessoryView = NO;
    
        return showInputAccessoryView;
    }
    

    This should hide InputAccessoryView even when the keyboard is resigned.

提交回复
热议问题