UISearchDisplayDelegate how to remove this opaque view?

前端 未结 4 688
醉话见心
醉话见心 2021-01-16 16:41

how can i programmatically show/hide this opaque view from UISearchDisplayController?

\"enter

4条回答
  •  萌比男神i
    2021-01-16 16:52

    Code given by elpsk is current but will not work in iOS7 and above
    Code working in both iOS6 and iOS7 is as below
    - add below notification in viewDidLoad

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil];
    


    Write below function

    - (void) keyboardWillShow {
          for( UIView *subview in self.view.subviews ) {
           if([subview  isMemberOfClass:[UIControl class]] ||
             ([[[subview  class] description] isEqualToString:@"UISearchDisplayControllerContainerView"])) {
              UIControl *v = (UIControl*)subview;
              if (v.alpha < 1) {
                v.hidden = YES;
              }
            }
          }
        }
    

    NOTE : Code just have one extra condition as in iOS7 UIControl class become UISearchDisplayControllerContainerView,

提交回复
热议问题