J'ai donc ce code pour créer mon inputAccessoryView lorsque le clavier apparaît:ObjC iOS11: TextField ne se présente pas lors de devenir premier intervenant dans inputAccessoryView
self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 1024, 44)];;
self.toolbar.backgroundColor = [UIColor blueColor];
NSMutableArray *toolbarItems = [[NSMutableArray alloc] init];
UILabel *nrLabel = [[UILabel alloc] initWithFrame:CGRectMake(7, 3, 140, 21)];
nrLabel.text = @"Number:";
[toolbarItems addObject:[[UIBarButtonItem alloc] initWithCustomView:nrLabel]];
self.nrTextField = [[UITextField alloc] initWithFrame:CGRectMake(8, 8, 140, 28)];
self.nrTextField.backgroundColor = [UIColor whiteColor];
[toolbarItems addObject:[[UIBarButtonItem alloc] initWithCustomView:self.nrTextField]];
UILabel *amountLabel = [[UILabel alloc] initWithFrame:CGRectMake(7, 3, 100, 21)];
amountLabel.text = @"Amount:";
[toolbarItems addObject:[[UIBarButtonItem alloc] initWithCustomView:amountLabel]];
self.amountTextField = [[UITextField alloc] initWithFrame:CGRectMake(8, 8, 100, 28)];
self.amountTextField.backgroundColor = [UIColor whiteColor];
[toolbarItems addObject:[[UIBarButtonItem alloc] initWithCustomView:self.amountTextField]];
self.toolbar.items = toolbarItems;
self.toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.nrTextField becomeFirstResponder];
return self.toolbar;
Il fonctionne bien aussi longtemps que je ne suis pas dites au nrTextField de devenir le premier répondeur. Est-ce que c'est illégal à faire?