Toolbar above Keyboard not showing - iOS 11

The toolbar above the keyboard is not visible on iOS 11.0. It works fine with 11.0 versions.

Here is my code for adding a toolbar. So what should I add to render it on iOS 11.0:

UIToolbar* customToolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 60)];     
        customToolBar.barStyle = UIBarStyleDefault;
        customToolBar.items = [NSArray arrayWithObjects:
              [[UIBarButtonItem alloc] initWithTitle:@"+ Contact" 
                                    style:UIBarButtonItemStylePlain 
                                    target:self 
                                    action:@selector(showPicker:)],
               [[UIBarButtonItem 
          alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
               target:nil 
               action:nil],
              [[UIBarButtonItem alloc] initWithTitle:@"- Contact" 
                                     style:UIBarButtonItemStylePlain 
                                    target:self 
                                    action:@selector(HidePicker:)],
                               nil];
        [customToolBar sizeToFit];
        self.textView.inputAccessoryView=customToolBar;

      

+3


source to share


2 answers


iOS 11 beta has an issue with displaying toolbars when not using the default keyboard (e.g. datepicker, picker). This can be solved by adding the following line to the pickerView:pickerView.translatesAutoresizingMaskIntoConstraints = false



+9


source


The following code works for me, try:

customToolBar.layoutIfNeeded() 

      



Looks like a bug in ios 11.

+1


source







All Articles