Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.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
Iphone 从nib加载的视图未接触事件_Iphone_Ios_Interface Builder_Xib_User Interaction - Fatal编程技术网

Iphone 从nib加载的视图未接触事件

Iphone 从nib加载的视图未接触事件,iphone,ios,interface-builder,xib,user-interaction,Iphone,Ios,Interface Builder,Xib,User Interaction,我用一些按钮创建了一个自定义键盘。我使用interface builder创建了它们,并创建了一个CustomKeyboardView文件 所以我有3个文件 CustomKeyboardView.h CustomKeyboardView.m CustomKeyboardView.xib 我像这样将此视图添加到我的UIViewController -(void)createCustomKeyboard{ //kbdCustom is an instance of CustomKeyboar

我用一些按钮创建了一个自定义键盘。我使用interface builder创建了它们,并创建了一个
CustomKeyboardView
文件

所以我有3个文件

  • CustomKeyboardView.h
  • CustomKeyboardView.m
  • CustomKeyboardView.xib
  • 我像这样将此视图添加到我的
    UIViewController

    -(void)createCustomKeyboard{
        //kbdCustom is an instance of CustomKeyboardView
        kbdCustom       =  [[[NSBundle mainBundle] loadNibNamed:@"CustomKeyBoardView" 
                                 owner:self options:nil] objectAtIndex:0];
        kbdCustom.delegate   =   self;
        CGRect frame         =   kbdCustom.frame;
        frame.origin.x       =   14.0;
        frame.origin.y       =   300.0;
        kbdCustom.frame      =   frame;
        kbdCustom.backgroundColor   =   [UIColor clearColor];
        [self.view addSubview:kbdCustom];
        [self.view bringSubviewToFront:kbdCustom];
    }
    
    我在屏幕上看到了自定义键盘。但我连一个按钮都碰不进去

    CustomKeyBoardView.m
    文件中没有什么特别之处。我有一些按钮处理程序来处理键盘上不同类型的按钮

    CustomKeyboardView.m 其他一些可能会帮助你(帮助我)的观点

  • 我反复检查按钮手柄。它们被连接到计算机上
    iAction
  • 我通过编程在键盘上添加了一个按钮(由 覆盖
    CustomKeyboardView.m
    中的
    awakeFromNib
    函数 当我将其添加到
    UIViewController
    时,也会显示该按钮。但是没有 用户交互也在那个按钮上
  • 问题中的
    UIViewController
    显示在
    UIPopOverController
    。我们在项目中使用故事板
  • 我已经添加了一些日志,以查看用户交互是否正常 在
    kbdCustom
    及其超级视图中启用。答案就在后面 肯定的

    NSLog(@"kbdCustom.userInteractionEnabled : %d"
       , kbdCustom.userInteractionEnabled);
    NSLog(@"superView.userInteractionEnabled : %d"
       , kbdCustom.superView.userInteractionEnabled);
    
    它的产量是

    kbdCustom.userInteractionEnabled : 1
    superView.userInteractionEnabled : 1
    
  • 当然,所有按钮上的用户交互都是
    YES
    ,并且 其中一个在interface builder中启用

  • 我已经调整了键盘的框架,使其在屏幕上向上移动 UITextField(正确接收触摸事件)。现在当我 单击键盘按钮,下面的UITextField将显示 触摸,好像键盘不在那里


  • 检查视图的自动调整大小,并设置其图层
    clipsToBound
    ,然后查看它是否仍然可见。如果没有,则意味着您的视图由于
    自动调整大小
    而缩小到最小大小,但它的子视图显示在
    基本视图
    的边界之外。在这种情况下,您可以看到它们,但不能触摸。

    检查视图的自动调整大小,并将其设置为图层
    clipsToBound
    ,然后查看它是否仍然可见。如果没有,则意味着您的视图由于
    自动调整大小
    而缩小到最小大小,但它的子视图显示在
    基本视图
    的边界之外。在这种情况下,您可以看到它们,但不能触摸。

    问题有点类似于此。。但我不知道投票结果如何。我认为问题在于框架(原点x,y)@Maulik我不这么认为。。因为我正确地看到了现场的按钮。此外,我将键盘移动到viewController视图的顶部(隐藏此键盘填充的文本字段),当我单击键盘按钮时,按钮下方的文本字段将被触摸。。这个问题有点像。。但我不知道投票结果如何。我认为问题在于框架(原点x,y)@Maulik我不这么认为。。因为我正确地看到了现场的按钮。同时,我将键盘移动到viewController视图的顶部(隐藏此键盘填充的文本字段),当我单击键盘按钮时,按钮下方的文本字段将被触摸..先生,您是我的英雄。。这是xib自动调整大小的问题。对于将来遇到此问题的任何人,请在“大小检查器”窗格中的
    CustomKeyboardView.xib
    中调整自动调整大小设置。。移除除顶部和左侧外的所有红色条。。Thanks@Krishnabhadra随时为您服务。:)如何使用自动布局实现同样的效果?同上。同样的问题,但使用自动布局,无法让我的xib识别触摸事件。先生,您是我的英雄。。这是xib自动调整大小的问题。对于将来遇到此问题的任何人,请在“大小检查器”窗格中的
    CustomKeyboardView.xib
    中调整自动调整大小设置。。移除除顶部和左侧外的所有红色条。。Thanks@Krishnabhadra随时为您服务。:)如何使用自动布局实现同样的效果?同上。同样的问题,但使用自动布局,无法让我的xib识别触摸事件。
    kbdCustom.userInteractionEnabled : 1
    superView.userInteractionEnabled : 1