UIAlertController中的多行可编辑文本UITextview? [英] Multiline editable text UITextview inside UIAlertController?
本文介绍了UIAlertController中的多行可编辑文本UITextview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 UIAlertController
中制作多行可编辑文本 UITextview
? UITextfield
支持单行,我们需要在弹出窗口中创建一个多行文本编辑框。
How can I make a multiline editable text UITextview
inside a UIAlertController
? UITextfield
supports a single line and we need to make a multiline text edit box in the pop up window.
推荐答案
这是一个很好的appraoch ...
This is good 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中的多行可编辑文本UITextview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文