0

How can I make a a UIButton which appears only when keyboard is popped up and it always stay above the keyboard, like an accessory to the keyboard, which is exclusive to that VC. I have a view in my VC which has 4 UIButtons and I want to add that view as an accessory view to my textField I'm writing this code.. but I'm getting a SIGABRT

@IBOutlet weak var colorSelector: UIView!
@IBOutlet weak var textField: UITextField!


override func viewDidLoad() {
    super.viewDidLoad()

    let customView = colorSelector
    textField.inputAccessoryView = customView

}
S.Verma
  • 199
  • 2
  • 14
  • The problem of your code is that, when you add `customView` to the `inputAccessoryView`, this `customView` already has parent view. so it will crash. – Elvin Mar 26 '17 at 05:04
  • A simple fix is that add `customView.removeFromSuperview()` before `textField.inputAccessoryView = customView` – Elvin Mar 26 '17 at 05:04
  • @Elvin My app is working but I can not see the `colorSelector` – S.Verma Mar 26 '17 at 05:16

0 Answers0