Reputation: 1352
I have a view with a couple of textfields in it. I am presenting this view using UIPopoverController.
The popover is working fine. But when I tap on the textfield, the keyboard does not show up. I programatically set one to the textfields to be the firstResponder
and it worked fine. But I want the user be able to tap on any textfield and enter info as they wish.
My code to start a popover controller is:
UIStoryboard *storyBoard = [self storyboard];
GeneralPickerViewController *picker = [storyBoard instantiateViewControllerWithIdentifier:@"GeneralPicker"];
[picker setDelegate:self];
[picker setPickerMode:@"NewParty"];
_popover = [[UIPopoverController alloc] initWithContentViewController:picker];
[_popover setDelegate:self];
[_popover setPopoverContentSize:CGSizeMake(286, 268)];
[_popover presentPopoverFromBarButtonItem:_createNewEntityButton permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
I have set the textfield's delegate to the GeneralPickerViewController class as the text fields are on the GeneralPickerVC's view.
Please let me know why this must be occurring.
Upvotes: 0
Views: 558
Reputation: 1413
Assuming the textfields are enabled and editable...
The default behaviour of a UITextField is to become first responder when it is tapped. No delegate methods are needed to achieve that. It also shouldn't matter if the view is presented in a UIPopoverController or not. So basically the desired behaviour (as described in the question) should be the default behaviour.
I have seen an issue like this before, caused by the textview frames which where (partially) outside the superview's frames (and therefore the area outside the view didn't respond to touches). This can be caused by an invalid autoresizingmask (or constraint). The view will be resized when presented in a popovercontroller.
Upvotes: 1