How to hide inputAccessoryView without dismissing keyboard

后端 未结 11 1161
挽巷
挽巷 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:22

    Oddly enough, none of these approaches worked in my case.

    I have a searchcontroller which pops up a standard Apple iOS keyboard if a particular search scope is selected, and a custom keyboard view with a collection view as the input field in cases of other scopes being selected. In both cases, an undesired accessory view was drawn on the screen when the input view was displayed.

    So,

    self.mySearch.searchbar.inputAccessoryView = nil // did not work
    
    [self.mySearch.searhbar.inputAccessoryView setHidden:YES] // did not work
    
    self.mySearch.inputAccessoryView = nil  // did not work
    
    self.mySearch.searchbar.inputAccessoryView.frame = CGRectZero //did not work
    
    [self.mySearch reloadInputViews]
    

    and various combinations thereof etc, etc.

    What did work was to delete to individual accessory items from the accessory view:

     // insert after assignments of mySearch delegates
    UITextInputAssistantItem *junk = [self.mySearch inputAssistantItem];
    junk.leadingBarButtonGroups = @[];
    junk.trailingBarButtonGroups = @[];
    

提交回复
热议问题