से प्रदर्शित होने से रोकें मेरे पास स्विफ्ट में UIAlertController
(अलर्ट शैली) है और यह सब ठीक काम करता है। हालांकि, UITextField
जिसे मैंने इसमें जोड़ा है वह एक वैकल्पिक फ़ील्ड है जिसे उपयोगकर्ता को टेक्स्ट दर्ज करने की आवश्यकता नहीं है। समस्या यह है कि जब मैं यह UIAlertController
दिखाता हूं, तो कीबोर्ड डिफ़ॉल्ट रूप से चयनित टेक्स्ट फ़ील्ड के साथ एक साथ दिखाई देता है। मैं नहीं चाहता कि कुंजीपटल तब तक दिखाई दे जब तक कि उपयोगकर्ता UITextField
टैप न करे। यह कैसे किया जा सकता है?कीबोर्ड को स्वचालित रूप से UIAlertController
let popup = UIAlertController(title: "My title",
message: "My message",
preferredStyle: .Alert)
popup.addTextFieldWithConfigurationHandler { (optionalTextField) -> Void in
optionalTextField.placeholder = "This is optional"
}
let submitAction = UIAlertAction(title: "Submit", style: .Cancel) { (action) -> Void in
let optionalTextField = popup.textFields![0]
let text = optionalTextField.text
print(text)
}
let cancelAction = UIAlertAction(title: "Cancel", style: .Default, handler: nil)
popup.addAction(cancelAction)
popup.addAction(submitAction)
self.presentViewController(popup, animated: true, completion: nil)
आप becomeFirstResponder कहीं और फोन बनाने किया जाना चाहिए। या आप स्वयं को कॉल कर सकते हैं। अंत में संपादन: चेतावनी प्रस्तुत करने के बाद/बाद में हाँ। –