InputAccessoryView内容显示在弹出键盘键上

时间:2014-03-19 19:42:50

标签: ios ios7 ios6 xcode5.1

自从我升级到Xcode 5.1后,我的inputAcoryoryView出现了问题。

Keyboard key behind InputAccessoryView

正如您在附图中看到的那样,inputAccesoryView内工具栏后面的键会弹出。我认为它与新版本的xcode有关,因为它与之前版本的xcode一样好。

创建和添加附件视图的代码:

    self.keyboardDoneButtonView = [[UIToolbar alloc] init];
    self.keyboardDoneButtonView.barStyle = UIBarStyleBlack;

    self.addEmailUITextField = [[UITextField alloc] init];
    [self.addEmailUITextField setReturnKeyType:UIReturnKeySend];
    [self.addEmailUITextField setBorderStyle:UITextBorderStyleRoundedRect];
    [self.addEmailUITextField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [self.addEmailUITextField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
    [self.addEmailUITextField setKeyboardType:UIKeyboardTypeEmailAddress];
    [self.addEmailUITextField setClearButtonMode:UITextFieldViewModeWhileEditing];
    [self.addEmailUITextField setKeyboardAppearance:UIKeyboardAppearanceDark];
    [self.addEmailUITextField setPlaceholder:NSLocalizedString(@"emailHint", nil)];

    self.cancel = [[UIButton alloc] init];
    [self.cancel setTitleColor:[UIColor khipuSecondaryColor] forState:UIControlStateNormal];
    [self.cancel setTitle:NSLocalizedString(@"cancel", nil) forState:UIControlStateNormal];
    [self.cancel addTarget:self action:@selector(hideAddEmailTextField) forControlEvents:UIControlEventTouchUpInside];
    [self.cancel sizeToFit];
    self.cancel.frame = CGRectMake((self.tableView.frame.size.width - (self.cancel.frame.size.width + 20)), self.cancel.frame.origin.y, self.cancel.frame.size.width, self.cancel.frame.size.height);
    self.addEmailUITextField.frame = CGRectMake(5, 7, (self.cancel.frame.origin.x - 10) - 5, 30);
    UIBarButtonItem *cancelUIBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.cancel];
    UIBarButtonItem *textFieldItem = [[UIBarButtonItem alloc] initWithCustomView:self.addEmailUITextField];

    [self.keyboardDoneButtonView setItems:[NSArray arrayWithObjects:textFieldItem,cancelUIBarButtonItem, nil]];
    [self.keyboardDoneButtonView sizeToFit];
    self.hiddenUITextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    self.hiddenUITextField.inputAccessoryView = self.keyboardDoneButtonView;
    [self.hiddenUITextField setKeyboardAppearance:UIKeyboardAppearanceDark];
    [self.addEmailUITextField setDelegate:self];

此代码用于在xcode升级之前正常工作

任何人都可以对这个问题有所了解吗?

2 个答案:

答案 0 :(得分:1)

发现问题!:这是一个类别。

我在UIView上有一个用于在子视图中搜索的类别。

我有一个名为

的方法
- (BOOL)containsView:(UIView *)aUIView;

这打破了这种行为。更改了方法的名称,现在工作正常。

我不知道,但也许我只选择私有API的签名。

感谢您的意见和建议,帮助我找到了麻烦的来源。

答案 1 :(得分:0)

我尝试了一个新项目,我没有问题......您的问题可能不在您的代码中,而是在您的Xcode设置中用于此项目...跳这将对您有帮助。

enter image description here