Question

I'm having troubles with my inputAccesoryView since I upgraded to Xcode 5.1.

Keyboard key behind InputAccessoryView

As you can see in the attached image, the keys popup behind the toolbar inside the inputAccesoryView. I think that it has something to do with the new version of xcode because it was ok with the previous version of xcode.

The code to create and add the accessory view:

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

This code use to work very well until the xcode upgrade

Can anyone shed some light into this issue?

Was it helpful?

Solution

Found the problem!: It was a category.

I've a category on UIView for searching inside subviews.

I had a method named

- (BOOL)containsView:(UIView *)aUIView;

Which was breaking the behaviour. Changed the name of the method and now it works fine.

I don't know, but maybe I just pick the signature of a private API.

Thanks for your comments and ideas, it helped me to find the source of trouble.

OTHER TIPS

I've try with a new project, and I have no issue... Your issue is probably not in your code, but in your Xcode settings for this project... Hop this will help you.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top