I am trying to set inputView
& inputAccessoryView
for UITextField
. But, as I start tap on textField only inputAccessoryView
is come from bottom.
Following is my code:
@IBOutlet weak var pickerView: UIPickerView!
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var toolBar: UIToolbar!
override func viewDidLoad() {
super.viewDidLoad()
self.textField.inputView = self.pickerView;
self.textField.inputAccessoryView = self.toolBar;
}
Thanks in advance.
I was really surprised when saw such a bug! You code looks 100% valid and must work. I even created small project to reproduce the problem. And succeeded with reproduction.
So my steps were:
Creare simple project with UITextView
in Xib that gets instantiated in application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!)
. Run and see that default keyboard gets displayed.
Add two more views to the Xib and connect them to MyViewController. And set inputView
and accessoryInputView
in viewDidLoad
as you did.
Run and see the problem.
Answer starts here:
Then I've just reset emulator, cleaned the build folder and run the code again. And it worked as expected!
It looks for me like a bug with either xCode or emulator(or may be both) but I cannot say who is guilty an why.
Screenshot (view with buttons is my keyboard :)