How to dismiss an UIAlertController and the keyboard simultaneously?

后端 未结 8 1236
离开以前
离开以前 2021-02-05 13:04

I have created a signup form with a UIAlertController and used the method addTextFieldWithConfigurationHandler to add a text field. But there is a litt

8条回答
  •  不思量自难忘°
    2021-02-05 13:32

    I had the exact same problem you had and found the solution incidentally. You probably don't need this anymore, but for the sake of others like me, here is the answer:

    Swift:

    override func canBecomeFirstResponder() -> Bool {
        return true
    }
    

    Objective-C:

    - (BOOL)canBecomeFirstResponder {
        return true;
    }
    

    Just add this code in the view controller handling the alert. Only tested in swift.

提交回复
热议问题