Programmatically adding UITextField to a dropdownlist <p>I have a tableview controlled by a UITableViewController. In this UITableViewController class I have added a <code>UITextField</code> programmatically to my UINavigationItem by adding these lines to my viewDidLoad method :</p> <pre><code>CGRect passwordTextFieldFrame = CGRectMake(20.0f, 100.0f, 280.0f, 31.0f); UITextField *passwordTextField = [[UITextField alloc] initWithFrame:passwordTextFieldFrame]; passwordTextField.placeholder = @"Password"; passwordTextField.backgroundColor = [UIColor whiteColor]; passwordTextField.textColor = [UIColor blackColor]; passwordTextField.font = [UIFont systemFontOfSize:14.0f]; passwordTextField.borderStyle = UITextBorderStyleRoundedRect; passwordTextField.clearButtonMode = UITextFieldViewModeWhileEditing; passwordTextField.returnKeyType = UIReturnKeyDone; passwordTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; passwordTextField.tag = 2; passwordTextField.autocapitalizationType = UITextAutocapitalizationTypeNone; passwordTextField.delegate = self; // ADD THIS LINE self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:passwordTextField]; </code></pre> <p>The <code>UITextField</code> is displayed correctly on my navigationbar but when I click it the textFieldDidBeginEditing never fires.</p> <p>I have added the to my header file along with the textFieldDidBeginEditing method.</p> <p>I tried doing the exact same thing in a view controlled by UIViewController and here the textFieldDidBeginEditing gets fired when I click the "textfield" - So I suspect the fact that I am adding the textfield to a UITableViewController is what's causing trouble.</p> <p>You might think - why didn't you add a "uinavigationbutton" to the "NavigationBar" instead - but I can't as the uidropdownmenu that I want to call when the button is being clicked only accepts a "UITextField".</p>