由于[uitextfield resignFirstResponder]导致应用崩溃

时间:2016-11-24 07:38:20

标签: ios objective-c uitextfield

视图中有三个textFields,如下图所示:

enter image description here

当我点击其中一个文本字段时,一个textField可以becomeFirstResponder,然后键盘出现。不会崩溃。 当我点击“完成”时或者制作其中一个文本字段 resignFirstResponder,键盘会消失。但是什么时候 键盘消失了,我的应用程序崩溃了。

错误:

  

iOS 8: [UICompatibilityInputViewController isKindOfClass:]:发送到解除分配的实例的消息0x7fd6b6074dd0

     

iOS 9: [UIInputWindowController parentViewController]:发送到解除分配的实例0x7fde7c004400的消息

     

iOS 10: [UICompatibilityInputViewController保留] ...

3 个答案:

答案 0 :(得分:0)

使用此代码:

and also set the delegates of the text fields

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == yourTextFieldOne) {
    [theTextField becomeFirstResponder];
} else if (theTextField == yourTextFieldTwo) {
    [self.textPassword becomeFirstResponder];
}else if (theTextField == yourTextFieldThree) {
    [theTextField resignFirstResponder];
}
return YES;
}

答案 1 :(得分:0)

$this->upload_config['upload_path'] = FCPATH . 'uploads/';

答案 2 :(得分:0)

    // 设置导航条
- (void)setupNav {
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.text = @"忘记密码";
    titleLabel.textColor = HexColor(0x795033);
    //    titleLabel.font = HNLightFont(20.0);
    titleLabel.font = [UIFont systemFontOfSize:20.0];
    [titleLabel sizeToFit];
    self.navigationItem.titleView = titleLabel;

    // 这2句代码起到向下偏移64的作用
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.automaticallyAdjustsScrollViewInsets = NO;
}