I've created a screen that has a UITextField on it. When I get a EditingDidBegin event, I resignFirstResponder, Bring up a Popover with another textField in it and for that TextField call the BecomeFirstResponder on it.
When it runs, I get Blinking insertion pointer and the X clear contents. Though no Keyboard. The Master UIView is set to UserInteractionEnabled:YES.
target action for First UITextField, its on its own view.
[textField addTarget:self action:@selector(wantsToEditValue:) forControlEvents:UIControlEventEditingDidBegin];
Target Action selector:
- (IBAction)wantsToEditValue:(id)sender {
// set notification so we can update from popover
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(saWriteValue:)
name:kRefreshFromPopover object:nil];
//we dont want the TagValue textfield to really be the first responder.
[textField resignFirstResponder];
[... setup popoverVC, and View. present popover...]
}
Here is the code to create the 2nd UITextField. This code is in the VC for the Popover..
- (void)viewDidLoad
{
if (IoUIDebug & IoUIDebugSelectorNames) {
NSLog(@"%@ - %@", [self description], NSStringFromSelector(_cmd) );
} [super viewDidLoad];
[self createElementInputControl];
[self createWriteButton];
//We want the input Focus
[textFieldInput becomeFirstResponder];
//Resize our view to handle the new width
CGRect newViewSize = CGRectMake(self.view.frame.origin.x,
self.view.frame.origin.y,
writeButton.frame.origin.x + writeButton.frame.size.width + kWriteElementOffset ,
self.view.frame.size.height);
[self.view setFrame:newViewSize];
}
Create Input Code:
-(void) createElementInputControl {
textFieldInput = [[UITextField alloc] initWithFrame:CGRectMake( kWriteElementOffset ,
kWriteElementHeightOffset,
kTagValueInputInitialWidth,
kWriteElementDefaultHeight)];
textFieldInput.borderStyle = UITextBorderStyleRoundedRect;
textFieldInput.clearButtonMode = UITextFieldViewModeWhileEditing;
textFieldInput.textAlignment = UITextAlignmentLeft;
[textFieldInput setDelegate:self];
[textFieldInput setKeyboardType:UIKeyboardTypeDefault];
// Set the value of the text
[textFieldInput setText:self.myTag.value];
CGSize textFieldInputSize = [textFieldInput.text sizeWithFont:textFieldInput.font];
//Set the Button Width
[textFieldInput setFrame:CGRectMake(textFieldInput.frame.origin.x, textFieldInput.frame.origin.y, textFieldInputSize.width + kTagValueInputWidthBuffer, textFieldInput.frame.size.height)];
[self.view addSubview:textFieldInput];
}
When I remove the becomeFirstResponder code, the Popover come up as normal, though no blinking insertion pointer. I tap the field, I get Insertion Pointer, X clear content button, and yes a Keyboard.
I want the keyboard to show without having to click in the new Text Field.
Thanks!