应用程序在ios中触摸UITextField时坠毁

问题描述:

我在故事板中添加了一个文本字段并将其与头文件链接起来。应用程序在ios中触摸UITextField时坠毁

现在,当我运行该应用程序我得到这样

[InputViewController _keyboard]: unrecognized selector sent to instance 

我试过很多东西,但它没有工作的错误。

这里是文本字段

@property (strong, nonatomic) IBOutlet UITextField *countryCode; 

这个接口是使用

NSString *body = [NSString stringWithFormat:@"country=%@", self.countryCode.text]; 

我该如何解决这个文本字段的值行?

文本字段的连接可以看到下面:

enter image description here

+0

你确定你没有使用自定义输入视图/自定义键盘可能是假的? –

+0

是的,我确信@Aviel Gross – KAR

+0

尝试删除UITextField并将其重新添加...可能出了点问题 – ddb

问题是与您的姓名:

@property (strong, nonatomic) InputViewController *inputViewController; 

苹果已经添加了类似名称的属性在UIResponder类:

@property (nonatomic, readonly, retain) UIInputViewController *inputViewController NS_AVAILABLE_IOS(8_0); 

这是发生了什么:

  1. 用户水龙头你的TextField。
  2. 由于类似命名的属性,UIKit框架会将您的自定义InputViewController错误为UIInputViewController类型的实例。
  3. UIKit尝试在您的InputViewController的实例上调用keyboard方法UIInputViewController
  4. keyboard方法在您的InputViewController上不存在,因为它不是UIInputViewController的实例。
  5. 您会收到无法识别的选择器发送到您的ViewController的错误,因为您的ViewController中没有此类方法,并且应用程序正确地崩溃。

更改该属性的名称,你应该没问题。

欲了解更多详情,请参阅Brian Nickel的回答here

另请参阅Apple的文档UIInputViewController

+0

很高兴知道:))...... – dreamBegin

+0

谢谢。你是对的@NSNoob – KAR

通过查看错误是告诉你,你发送一个信息,它是不是在这所定义的类就是为什么编译器告诉你,你发送的信息没有被课程认可。检查你创建的对象和出口,并确保你发送正确的信息到正确的课程或实例,并尝试删除出口你之前创建的那个现在不存在。

+0

没有问题是与名称'inputViewController'这会导致与UIKit – NSNoob

+0

问题也许你是对的@NSNoob它只是一个预测,我做了实际问题只能在代码可用时找到。 – dreamBegin

+0

谢谢。问题出在@ NSNoob – KAR