Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';找不到支持键盘iPhone纵向数字广告类型4的键盘平面;使用3876877096_肖像_iPhone-Simple-Pad_默认值_Iphone_Ios8 - Fatal编程技术网

Can';找不到支持键盘iPhone纵向数字广告类型4的键盘平面;使用3876877096_肖像_iPhone-Simple-Pad_默认值

Can';找不到支持键盘iPhone纵向数字广告类型4的键盘平面;使用3876877096_肖像_iPhone-Simple-Pad_默认值,iphone,ios8,Iphone,Ios8,我已经为iPhone和SDK下载了iOS 8 Gold Master 我测试了这个应用程序,它运行得很好,除了一件事 我有一个文本字段,如果用户想要键入内容,将在其中显示数字键盘。此外,当键盘显示时,会在空白区域添加一个自定义按钮 - (void)addButtonToKeyboard { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { // create custom button

我已经为iPhone和SDK下载了iOS 8 Gold Master

我测试了这个应用程序,它运行得很好,除了一件事

我有一个文本字段,如果用户想要键入内容,将在其中显示数字键盘。此外,当键盘显示时,会在空白区域添加一个自定义按钮

- (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];
            }
        }
    }

}
-(无效)添加按钮键盘
{
如果(用户界面习惯用法()==UIUserInterfaceIdiomPhone)
{
//创建自定义按钮
UIButton*doneButton=[UIButton按钮类型:UIButtonTypeCustom];
doneButton.frame=CGRectMake(-2163106,53);
doneButton.adjustsImageWhenHighlighted=否;
[doneButton setImage:[UIImage ImageName:@“DoneUp.png”]用于状态:UIControlStateNormal];
[doneButton setImage:[UIImage ImageName:@“DoneDown.png”]用于状态:UIControlStateHighlighted];
[doneButton addTarget:self action:@selector(saveNewLead:)for ControlEvents:UIControlEventTouchUpInside];
//定位键盘视图
UIWindow*tempWindow=[[UIApplication sharedApplication]windows]对象索引:1];
UIView*键盘;
对于(int i=0;i=3.2){

如果([[keyboard description]hasPrefix:@“可能您应该重置按钮的框架,我也遇到了一些问题,请按如下方式记录键盘视图:

ios8:

“”
8日之前:

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

更新到最新的Xcode Beta版后,我也遇到了这个问题。模拟器上的设置已刷新,因此检测到笔记本电脑(外部)键盘。如果您只需按下:


iOS模拟器->硬件->键盘->连接硬件键盘


因此,如果未选中该条目,则软件键盘将再次显示。

我也遇到了此问题,并找到了解决方案

下面是适用于iOS 8.0和以下版本的代码

我已经在iOS 7和8.0(Xcode版本6.0.1)上测试了它

-(无效)添加按钮键盘
{
//创建自定义按钮
self.doneButton=[UIButton-buttonwhithtype:UIButtonTypeCustom];
//此代码将在iOS 8.3和8.4上运行。
如果([[[UIDevice currentDevice]systemVersion]floatValue]>=8.3){
self.doneButton.frame=CGRectMake(0,[[UIScreen mainScreen]边界].size.height-53106,53);
}否则{
self.doneButton.frame=CGRectMake(0,163+44,106,53);
}
self.doneButton.adjustsImageWhenHighlighted=否;
[self.doneButton setTag:67123];
[self.doneButton setImage:[UIImage ImageName:@“doneup1.png”]用于状态:UIControlStateNormal];
[self.doneButton setImage:[UIImage ImageName:@“donedown 1.png”]用于状态:UIControlStateHighlighted];
[self.doneButton addTarget:self action:@selector(doneButton:)for controlEvents:UIControlEventTouchUpInside];
//定位键盘视图
int windowCount=[[UIApplication sharedApplication]windows]计数];
如果(windowCount<2){
返回;
}
UIWindow*tempWindow=[[UIApplication sharedApplication]windows]对象索引:1];
UIView*键盘;
对于(int i=0;i<[tempWindow.subviews计数];i++){
键盘=[tempWindow.subviews objectAtIndex:i];
//找到键盘后,添加按钮
如果([[[UIDevice currentDevice]systemVersion]floatValue]>=8.3){
UIButton*searchbtn=(UIButton*)[带标签的键盘视图:67123];
如果(searchbtn==nil)
[键盘添加子视图:self.doneButton];
}否则{

如果([[keyboard description]hasPrefix:@“我在使用分发资源调配配置文件时遇到同样的问题。请检查您是否使用开发者配置文件使用模拟器运行应用程序

iOS模拟器->硬件->键盘->iOS使用与OSX相同的布局


如果有人在他们的设备上运行他们的应用程序,这将解决问题

我使用的是带ios 8的xcode,只需取消选中模拟器->硬件->键盘->连接硬件键盘中的连接硬件键盘选项


这将解决问题。

既然警告仍然存在,为什么选择长代码而不使用UIToolbar

UIToolbar适用于任何iOS版本这是我的示例代码

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];
}

由于两个不同的原因,我收到了相同的错误消息,因此您可以将它们添加到调试清单中:

上下文:Xcode 6.4,iOS:8.4。我添加了一个带有自定义
UIBarButton
s的工具栏,以加载
UIKeyboardTypeNumberPad
(Swift:
UIKeyboardType.numberPad
),即“完成”和“+/-”。我在以下情况下遇到此问题:

  • 我的UIToolbar被声明为属性,但我忘记显式地alloc/init它

  • 我删去了最后一行,
    [myCustomToolbar sizeToFit];
    ,听起来它和Holden的答案是同一个系列(我的代码在这里:)

  • 祝你好运,去吧


    iOS模拟器->硬件->键盘->取消选中连接硬件键盘选项

    这将解决问题


    执行上述步骤后,您的MAC键盘将无法工作,您必须使用模拟器键盘。

    模拟器尝试在MAC上查找数字键盘,但找不到(MacBook Pro、MacBook Air和“普通/小型”键盘没有)。您可以取消选择“连接硬件键盘”选项,也可以忽略错误消息,这对应用程序没有负面影响。

    好的,这里有一个简单的修复方法,用于在iOS 9、iOS 8及以下版本的应用程序中显示“完成”按钮,并在出现类似错误时在应用程序中工作。运行应用程序并通过“查看”H查看后可以观察到该错误iArchy“(即,当应用程序在设备上运行并在情节提要中检查您的视图时,单击调试区域栏上的“视图层次结构”图标),与iOS 8及以下版本相比,iOS 9中的键盘显示在不同的窗口上,并且
    "<UIInputSetContainerView: 0x7fef0364b0d0; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x7fef0364b1e0>>"
    
    "<UIPeripheralHostView: 0x11393c860; frame = (0 352; 320 216); autoresizesSubviews = NO; layer = <CALayer: 0x11393ca10>>"
    
    - (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;
        }
    }
    
    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];
    }
    
    - (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;
        }
    }
    
    - (void)removeKeyboardButton {
    
    id windowTemp = [self addButtonToKeyboard];
    
    if (windowTemp) {
    
        for (UIView *doneButton in [windowTemp subviews]) {
            if ([doneButton isKindOfClass:[UIButton class]]) {
                [doneButton setHidden:TRUE];
            }
        }
      }
    }
    
    Simulator -> Hardware -> Keyboard -> Connect Hardware Keyboard