ChatGPT解决这个技术问题 Extra ChatGPT

Can't find keyplane that supports type 4 for keyboard iPhone-Portrait-NumberPad; using 3876877096_Portrait_iPhone-Simple-Pad_Default

I've downloaded iOS 8 Gold Master for the iPhone and the SDK.

I tested the app and it works fine, except for one thing.

I have a text field where a number pad will appear if the user wants to type something, in addition, a custom button is added to the empty area when the keyboard shows up.

- (void)addButtonToKeyboard
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        // create custom button
        UIButton * doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
        doneButton.frame = CGRectMake(-2, 163, 106, 53);
        doneButton.adjustsImageWhenHighlighted = NO;
        [doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
        [doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
        [doneButton addTarget:self action:@selector(saveNewLead:) forControlEvents:UIControlEventTouchUpInside];

        // locate keyboard view
        UIWindow * tempWindow = [[[UIApplication sharedApplication] windows]objectAtIndex:1];
        UIView* keyboard;
        for(int i=0; i<[tempWindow.subviews count]; i++) 
        {
            keyboard = [tempWindow.subviews objectAtIndex:i];

            // keyboard view found; add the custom button to it
            if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
                if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
                    [keyboard addSubview:doneButton];
            } else {
                if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
                    [keyboard addSubview:doneButton];
            }
        }
    }

}

This was working fine up till now.

First of all, I'm getting this warning:

Can't find keyplane that supports type 4 for keyboard iPhone-Portrait-NumberPad; using 3876877096_Portrait_iPhone-Simple-Pad_Default

then that custom button is also not showing, which I think because of these 2 lines:

if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)

and

if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)

Any suggestions?

For the folks coming here from the search engine: I got the error after localizing an app (Xcode 11). In the menu of the Simulator app uncheck: "I/O" > "Keyboard" > "Use the Same Keyboard Language as macOS". I had to cycle through Cmd-K / Cmd-Shift-K to let the soft keyboard behave well again.

a
aquagremlin

I too had this problem after updating to the latest Xcode Beta. The settings on the simulator are refreshed, so the laptop (external) keyboard was being detected. If you simply press:

iOS Simulator -> Hardware -> Keyboard -> Connect Hardware Keyboard

so that the entry is UNchecked then the software keyboard will be displayed once again.


I probably hit Shift+Cmd+K by mistake!
iOS Simulator -> Hardware -> Keyboard -> Connect Hardware Keyboard uncheck it and it solved
This only skips the check that throws the error when you're on a simulator - the bug and keyboard swap will still happen in the real world on real devices.
If this doesn't work, then select Simulator -> Hardware -> Erase all content and settings.
For Version 11.5; iOS Simulator -> I/O -> Keyboard -> Connect Hardware Keyboard
d
darkman

The emulator tries to find a numeric keypad on the mac, but this is not found (MacBook Pro, MacBook Air and "normal/small" keyboard do not have it). You can deselect the option Connect Hardware Keyboard or just ignore the error message, it will have no negative effect on application.


Thanks for explaining the reason. Everyone says to uncheck "Connect Hardware Keyboard" but you gave a reason for doing the same.
Perfect.. this is what I was looking for ... reason behind the warning.
H
Hitesh Surani

Just Go to

iOS Simulator -> Hardware -> Keyboard -> Uncheck the Connect Hardware Keyboard Option.

This will fix the issue.

Your MAC keyboard will not work after performing the above step, You have to use simulator keyboard.


u
user4600710

I am using xcode with ios 8 just uncheck the connect harware keyboard option in your Simulator-> Hardware-> Keyboard-> Connect Hardware Keyboard.

This will solve the issue.


Literally no idea where this iOS simulator is. Or where hardware is? You're talking about the actual simulator like the thing that looks like an iPhone, and through that I find hardware?
A
Alex Zavatone

I also had this problem and found the solution.

Below is the code which will work for iOS 8.0 and also for below versions.

I have tested it on iOS 7 and 8.0 (Xcode Version 6.0.1)

- (void)addButtonToKeyboard
    {
    // create custom button
    self.doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
            //This code will work on iOS 8.3 and 8.4. 
       if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.3) {
            self.doneButton.frame = CGRectMake(0, [[UIScreen mainScreen]   bounds].size.height - 53, 106, 53);
      } else {
           self.doneButton.frame = CGRectMake(0, 163+44, 106, 53);
      }

    self.doneButton.adjustsImageWhenHighlighted = NO;
    [self.doneButton setTag:67123];
    [self.doneButton setImage:[UIImage imageNamed:@"doneup1.png"] forState:UIControlStateNormal];
    [self.doneButton setImage:[UIImage imageNamed:@"donedown1.png"] forState:UIControlStateHighlighted];

    [self.doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];

    // locate keyboard view
    int windowCount = [[[UIApplication sharedApplication] windows] count];
    if (windowCount < 2) {
        return;
    }

    UIWindow *tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
    UIView *keyboard;

    for (int i = 0; i < [tempWindow.subviews count]; i++) {
        keyboard = [tempWindow.subviews objectAtIndex:i];
             // keyboard found, add the button
          if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.3) {

            UIButton *searchbtn = (UIButton *)[keyboard viewWithTag:67123];
            if (searchbtn == nil)
                [keyboard addSubview:self.doneButton];

            } else {   
                if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES) {
              UIButton *searchbtn = (UIButton *)[keyboard viewWithTag:67123];
                   if (searchbtn == nil)//to avoid adding again and again as per my requirement (previous and next button on keyboard)
                [keyboard addSubview:self.doneButton];

        } //This code will work on iOS 8.0
        else if([[keyboard description] hasPrefix:@"<UIInputSetContainerView"] == YES) {

            for (int i = 0; i < [keyboard.subviews count]; i++)
            {
                UIView *hostkeyboard = [keyboard.subviews objectAtIndex:i];

                if([[hostkeyboard description] hasPrefix:@"<UIInputSetHost"] == YES) {
                    UIButton *donebtn = (UIButton *)[hostkeyboard viewWithTag:67123];
                    if (donebtn == nil)//to avoid adding again and again as per my requirement (previous and next button on keyboard)
                        [hostkeyboard addSubview:self.doneButton];
                }
            }
        }
      }
    }
 }

>

- (void)removedSearchButtonFromKeypad 
    {

    int windowCount = [[[UIApplication sharedApplication] windows] count];
    if (windowCount < 2) {
        return;
    }

    UIWindow *tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];

    for (int i = 0 ; i < [tempWindow.subviews count] ; i++)
    {
        UIView *keyboard = [tempWindow.subviews objectAtIndex:i];

           if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.3){
                [self removeButton:keyboard];                  
            } else if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES) {
                  [self removeButton:keyboard];

             } else if([[keyboard description] hasPrefix:@"<UIInputSetContainerView"] == YES){

            for (int i = 0 ; i < [keyboard.subviews count] ; i++)
            {
                UIView *hostkeyboard = [keyboard.subviews objectAtIndex:i];

                if([[hostkeyboard description] hasPrefix:@"<UIInputSetHost"] == YES) {
                    [self removeButton:hostkeyboard];
                }
            }
        }
    }
}


- (void)removeButton:(UIView *)keypadView 
    {
    UIButton *donebtn = (UIButton *)[keypadView viewWithTag:67123];
    if(donebtn) {
        [donebtn removeFromSuperview];
        donebtn = nil;
    }
}

Hope this helps.

But , I still getting this warning:

Can't find keyplane that supports type 4 for keyboard iPhone-Portrait-NumberPad; using 3876877096_Portrait_iPhone-Simple-Pad_Default

Ignoring this warning, I got it working. Please, let me know if you able to get relief from this warning.


For addDoneButton or removeDoneButton: stackoverflow.com/questions/26031798/… I run the above code in XCode-5.1.1 in the iOS-6/7/8 devices. Working perfectly.
-(void)doneButton:(UIButton *)sender { NSLog(@"fdsfdsdsf"); }
I did all this actions but done button is not clickable, can you hepl me?
With the latest release of iOS 8.3 and above something has changed that fails the previous posted code. I have added the check for iOS 8.3 and above, It may stops working for the future iOS version. Please check above.
@IGW, in iOS9 view hierarchy for the keyboard is much simpler and above code (and similar ones) fails to find the proper window. Have you found a solution by any chance for iOS9?
t
tdw

Go into Simulator-> Hardware->Keyboard and unchecking Connect Hardware Keyboard.

The same as many answers above BUT did not change for me until I quit and restart the simulator. xcode 8.2.1 and Simulator 10.0.


c
carlson

I had the same problem in Xcode 8.1 and iOS 10.1. What worked for me was going into Simulator-> Hardware->Keyboard and unchecking Connect Hardware Keyboard.


R
Ronaldoh1

Run the app using the simulator

iOS Simulator-> Hardware-> Keyboard -> iOS uses same layout as OS X

This will fix the issue if anyone out there is running their app on their device


H
Hitesh Surani

In your iOS App can't find a Numeric Keypad attached to your OS X. So you just need to Uncheck connect Hardware Keyboard option in your Simulator, in the following path just for testing purpose:

Simulator -> Hardware -> Keyboard -> Connect Hardware Keyboard

This will resolve the above issue.

I think you should see the below link too. It says it's a bug in the XCode at the end of that Forum post thread! Reference


A
AmitaiB

I got the same error message for two separate reasons, so you can add them to your debugging checklist:

Context: Xcode 6.4, iOS:8.4. I was adding a toolbar with custom UIBarButtons to load with the UIKeyboardTypeNumberPad (Swift: UIKeyboardType.numberPad) , namely "Done" and "+/-". I had this problem when:

My UIToolbar was declared as a property, but I had forgotten to explicitly alloc/init it. I had left off the last line, [myCustomToolbar sizeToFit];, which sounds like it's the same family as Holden's answer (my code here: https://stackoverflow.com/a/32016397/4898050).

Good luck


K
KIO

I had the same problem using distribution provisioning profile. Check that you use developer profile


N
NFerocious

Why the long code and not use the UIToolbar? since the warning is still persist?

UIToolbar is working for any iOS Version here's my sample code

UIToolbar *doneToolbar = [[UIToolbar alloc] initWithFrame:(CGRect){0, 0, 50, 50}]; // Create and init
doneToolbar.barStyle = UIBarStyleBlackTranslucent; // Specify the preferred barStyle
doneToolbar.items = @[
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil], 
[[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStylePlain target:self action:@selector(doneEditAction)] // Add your target action
]; // Define items -- you can add more

yourField.inputAccessoryView = doneToolbar; // Now add toolbar to your field's inputview and run
[doneToolbar sizeToFit]; // call this to auto fit to the view

- (void)doneEditAction {
    [self.view endEditing:YES];
}

b
bin k

I had this problem with Flutter, When I click on my input the keyboard doesn't appear, I fixed it by upgrade the widget where there the Form widget to stateFull.

but the warning is still here.


b
bummi

Maybe you should reset frame of the button, I had some problem too, and nslog the view of keyboard like this:

ios8:

"<UIInputSetContainerView: 0x7fef0364b0d0; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x7fef0364b1e0>>"

before8:

"<UIPeripheralHostView: 0x11393c860; frame = (0 352; 320 216); autoresizesSubviews = NO; layer = <CALayer: 0x11393ca10>>"

V
Vick Swift

Okay here's a simple fix for getting 'done' button to show and work in an app in both iOS 9, iOS 8 and below when I got similar error. It could be observed after running an app and viewing it via 'View's Hierarchy' (i.e. clicking on the 'View Hierarchy' icon from Debug Area bar while app is running on device and inspecting your views in Storyboard), that the keyboard is presented on different windows in iOS 9 compared to iOS 8 and below versions and have to be accounted for. addButtonToKeyboard

- (id)addButtonToKeyboard
{
if (!doneButton)
{
   // create custom button
    UIButton * doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
    doneButton.frame = CGRectMake(-2, 163, 106, 53);
    doneButton.adjustsImageWhenHighlighted = NO;
    [doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
    [doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
    [doneButton addTarget:self action:@selector(saveNewLead:) forControlEvents:UIControlEventTouchUpInside];
}

NSArray *windows = [[UIApplication sharedApplication] windows];
//Check to see if running below iOS 9,then return the second window which bears the keyboard   
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 9.0) {
return windows[windows.count - 2];
}
else {
UIWindow* keyboardWithDoneButtonWindow = [ windows lastObject];
return keyboardWithDoneButtonWindow;
    }
}

And this is how you could removeKeyboardButton from keyboard if you want.

- (void)removeKeyboardButton {

id windowTemp = [self addButtonToKeyboard];

if (windowTemp) {

    for (UIView *doneButton in [windowTemp subviews]) {
        if ([doneButton isKindOfClass:[UIButton class]]) {
            [doneButton setHidden:TRUE];
        }
    }
  }
}