Reputation: 8376
I have a parent view controller that acts as a container for a UIPageViewController
and another UIViewController
(called commentsViewController
). I want to show the inputAccessoryView
inside the commentsViewController
however it doesn't seem to be working. I have added the commentsViewController
to the parent like so:
commentsViewController = storyboard!.instantiateViewControllerWithIdentifier("CommentsViewController")! as! CommentsViewController
self.addChildViewController(commentsViewController)
self.view.addSubview(commentsViewController.view)
//...I have set some autolayout constraints here
commentsViewController.didMoveToParentViewController(self)
Then inside CommentsViewController
, I have the following:
@IBOutlet var customView: UIView!
override var inputAccessoryView: UIView {
return customView
}
override func canBecomeFirstResponder() -> Bool {
return true
}
override func viewDidLoad() {
super.viewDidLoad()
self.becomeFirstResponder()
}
Unfortunately this doesn't work and the inputAccessoryView is not displayed... Can anyone see what I'm missing?
Thank you.
Upvotes: 0
Views: 879
Reputation: 8376
Turns out that because I was animating the view, becomeFirstResponder()
automatically returned false. After the animation it works fine.
Upvotes: 3