I tried this to add UITextField to a UIToolbar but got a run-time error with reason as: [UITextField view]: unrecognized selector sent to instance …
[toolbar setItems:[NSArray arrayWithObjects:textField, nil]];
toolbar is an instance of UIToolbar and textField is an instance of UITextField.
The
itemsof aUIToolbarhave to be of typeUIBarButtonItem. UseinitWithCustomView:to create a toolbar item that contains your text field.