I have an UIToolbar with a TextField and a Button as UIBarButtonItem. I'm trying to use this toolbar as an inputAccessory for the keyboard when the user taps the TextField inside the toolbar.
I found this question that tries to solve the same problem. Unfortunately, the solution was not effective.
What i'm trying is:
class ChatViewController: UIViewController, CLLocationManagerDelegate, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var chatTableView: UITableView!
@IBOutlet weak var chatToolbar: UIToolbar!
@IBOutlet weak var textFieldBarButtonItem: UIBarButtonItem!
override func viewDidAppear(animated: Bool) {
super.viewDidLoad()
self.chatTableView.delegate = self
self.chatTableView.dataSource = self
self.chatToolbar.removeFromSuperview()
}
override var inputAccessoryView: UIView{
get{
return self.chatToolbar
}
}
override func canBecomeFirstResponder() -> Bool {
return true
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell = UITableViewCell()
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
}
}
And what i'm getting back is:
*** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason:
'child view controller:<UICompatibilityInputViewController: 0x13ff34e00> should have parent view controller:
<App.ChatViewController: 0x13ff21cc0> but requested parent is:<UIInputWindowController: 0x1400b4600>'
Any ideas?