accessory bar hiding in ios 9

匿名 (未验证) 提交于 2019-12-03 08:48:34

问题:

Hi can someone help me out

i want to hide the accessory bar from keyboard in ios 9 its working find till ios 8 but in ios 9 i am not able to hide the accessory bar i tired this code but its not working

for (UIView *possibleFormView in [keyboardWindow subviews]) {      if([[possibleFormView description] hasPrefix:@"<UIInputSetContainerView"])     {         for(UIView *view1 in possibleFormView.subviews)         {             if([[view1 description] hasPrefix:@"<UIInputSetHostView"])             {                 for (UIView *peripheralView_sub in view1.subviews) {                     //Hides the backdrop (iOS 8)                     if ([[peripheralView_sub description] hasPrefix:@"<UIKBInputBackdropView"] ) {                         [[peripheralView_sub layer] setOpacity:0.0];                     }                     if([[peripheralView_sub description] hasPrefix:@"<<_UIRemoteKeyboardPlaceholderView"])                     {                         CGRect newRect= peripheralView_sub.frame;                         newRect.origin.y=44;                         newRect.size.height=398-44;                         peripheralView_sub.frame=newRect;                          peripheralView_sub.clipsToBounds=false;                          for(UIView *remoteKeyboardView in peripheralView_sub.subviews)                         {                             NSLog(@"Remote Key View %@",remoteKeyboardView);                         }                     }                     if ([[peripheralView_sub description] hasPrefix:@"<UIWebFormAccessory"]) {                          for (UIView *UIInputViewContent_sub in peripheralView_sub.subviews) {                              CGRect frame1 = UIInputViewContent_sub.frame;                             frame1.size.height = 0;                             peripheralView_sub.frame = frame1;                             UIInputViewContent_sub.frame = frame1;                             [[peripheralView_sub layer] setOpacity:0.0];                         }                          CGRect viewBounds = peripheralView_sub.frame;                         viewBounds.size.height = 0;                         peripheralView_sub.frame = viewBounds;                         [peripheralView_sub removeFromSuperview];                     }                 }              }         }     } } 

回答1:

You can hide it by removing all assistant bar buttons from the active textfield.

UITextField *textField = ... if ([textField respondsToSelector:@selector(inputAssistantItem)]) {     UITextInputAssistantItem *inputAssistantItem = [textField inputAssistantItem];     inputAssistantItem.leadingBarButtonGroups = @[];     inputAssistantItem.trailingBarButtonGroups = @[]; } 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!