मैं UIAlertController
के अंदर एक मल्टीलाइन संपादन योग्य टेक्स्ट UITextview
कैसे बना सकता हूं? UITextfield
एक लाइन का समर्थन करता है और हमें पॉप अप विंडो में एक मल्टीलाइन टेक्स्ट एडिट बॉक्स बनाने की आवश्यकता है।मल्टीलाइन संपादन योग्य टेक्स्ट UITextview?
उत्तर
यह अच्छा appraoch है ...
func popUpController()
{
let alertController = UIAlertController(title: "\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)
let margin:CGFloat = 8.0
let rect = CGRectMake(margin, margin, alertController.view.bounds.size.width - margin * 4.0, 100.0)
let customView = UITextView(frame: rect)
customView.backgroundColor = UIColor.clearColor()
customView.font = UIFont(name: "Helvetica", size: 15)
// customView.backgroundColor = UIColor.greenColor()
alertController.view.addSubview(customView)
let somethingAction = UIAlertAction(title: "Something", style: UIAlertActionStyle.Default, handler: {(alert: UIAlertAction!) in print("something")
print(customView.text)
})
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: {(alert: UIAlertAction!) in print("cancel")})
alertController.addAction(somethingAction)
alertController.addAction(cancelAction)
self.presentViewController(alertController, animated: true, completion:{})
}
आप UIAlertController
में बहु-लाइन टेक्स्ट व्यू नहीं बना सकते हैं। इसके लिए आपको अपना खुद का UIAlertController
बनाना होगा।
धन्यवाद यह अच्छा दृष्टिकोण मेरे स्वयं के कस्टम बनाने के लिए है, पिछले पर मैं अपने जवाब में नीचे की तरह इसे बनाने के लिए है। बहुत बहुत धन्यवाद मुझे एक अच्छा लिंक दे। – Vishal
मैं विशाल के दृष्टिकोण के लिए कुछ सुधार किया।
- प्लेसहोल्डर के रूप में प्रारंभिक हल्के भूरे रंग के पाठ को प्रदर्शित करने के लिए UITextViewDelegate विधि जोड़ा गया और इसे TextViewDidBeginEditing पर हटा दें।
इसे दृश्यमान बनाने के लिए टेक्स्ट दृश्य सीमा चौड़ाई, सीमा रंग और पृष्ठभूमि रंग सेट करें।
class ViewController: UIViewController, UITextViewDelegate { ... @IBAction func showAlert(sender: AnyObject) { let alertController = UIAlertController(title: "Hello, I'm alert! \n\n\n\n\n\n\n", message: "", preferredStyle: .Alert) let rect = CGRectMake(15, 50, 240, 150.0) let textView = UITextView(frame: rect) textView.font = UIFont(name: "Helvetica", size: 15) textView.textColor = UIColor.lightGrayColor() textView.backgroundColor = UIColor.whiteColor() textView.layer.borderColor = UIColor.lightGrayColor().CGColor textView.layer.borderWidth = 1.0 textView.text = "Enter message here" textView.delegate = self alertController.view.addSubview(textView) let cancel = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil) let action = UIAlertAction(title: "Ok", style: .Default, handler: { action in let msg = (textView.textColor == UIColor.lightGrayColor()) ? "" : textView.text print(msg) }) alertController.addAction(cancel) alertController.addAction(action) self.presentViewController(alertController, animated: true, completion: {}) } func textViewDidBeginEditing(textView: UITextView) { if textView.textColor == UIColor.lightGrayColor(){ textView.text = "" textView.textColor = UIColor.darkGrayColor() } } }
आपको बहुत बहुत धन्यवाद। यह वही है जैसा मैं चाहता था। लेकिन संपादन शुरू होने पर यह ऊपर नहीं जाता है। क्या आपके पास इसका समाधान है। –
- 1. उपयोगकर्ता द्वारा UITextView संपादन योग्य नहीं है
- 2. UITextView इमोटिकॉन्स संपादन
- 3. आईफोन UITextView स्क्रॉल करने योग्य लेकिन संपादन योग्य नहीं
- 4. गैर-संपादन योग्य टेक्स्ट-फील्ड
- 5. संपादन योग्य और गैर-संपादन योग्य
- 6. UITextView विशेषता टेक्स्ट
- 7. मल्टीलाइन टेक्स्ट
- 8. मल्टीलाइन संपादन टेक्स्ट के आकार को कैसे ठीक करें
- 9. संपादन टेक्स्ट में गैर-संपादन योग्य स्ट्रिंग को शामिल करें
- 10. एक्सेल कोशिकाओं में मल्टीलाइन टेक्स्ट
- 11. चयन योग्य लेकिन संपादन योग्य HTML टेक्स्ट फ़ील्ड
- 12. UITextView, संपादन करते समय स्क्रॉल करें?
- 13. मुझे QWebView संपादन योग्य
- 14. UITextView पेजिंग सक्षम टेक्स्ट
- 15. संपादन योग्य
- 16. बूटस्ट्रैप एक्स-संपादन योग्य
- 17. सीएसएस को कैसे रोकें ': टेक्स्ट' संपादन योग्य होने पर पहले 'div` संपादन योग्य है?
- 18. सामग्री-संपादन योग्य div
- 19. सामग्री संपादन योग्य div
- 20. एक संपादन टेक्स्ट
- 21. UITextView
- 22. UITextView रिच टेक्स्ट?
- 23. UITextView
- 24. UITextView
- 25. एंड्रॉइड: संपादन टेक्स्ट
- 26. मल्टीलाइन टेक्स्ट को नॉकआउटज बाइंडिंग
- 27. टेक्स्ट एरिया में ध्यान रखें जब गैर-संपादन योग्य
- 28. किसी सामग्री से टेक्स्ट निकालना संपादन योग्य div
- 29. गैर संपादन योग्य सामग्री के साथ रिच टेक्स्ट, AngularJS
- 30. संपादन योग्य div
मैंने इस पर कुछ शोध किया था। ऐसा लगता है कि यूआईएलर्ट कंट्रोलर का आंतरिक कार्यान्वयन बदल गया है (मैं आईओएस 9 पर काम कर रहा हूं) और यह काम नहीं करेगा। सिर्फ आपकी जानकारी के लिए। –