gpt4 book ai didi

swift - 如何从 Swift 中的段落开始到 UITextView

转载 作者:行者123 更新时间:2023-11-30 11:00:46 25 4
gpt4 key购买 nike

如何在 UITextView 中开始一个带有一点空间的新行,我相信称为段落?

enter image description here

最佳答案

你需要做的是让 Controller 面对 UITextFieldDelegate

例如:

class ViewController: UIViewController,UITextFieldDelegate 
{
//link the textfield
@IBOutlet weak var textField: UITextField!

override func viewDidLoad()
{
super.viewDidLoad()
// link the delegate to the textfield
textField.delegate = self
}

//this function detects the return button when it's pressed

func textFieldShouldReturn(_ textField: UITextField) -> Bool
{
//since we always want to start a new line with space we override the default function

textField.text += "\n "
return false
}

关于swift - 如何从 Swift 中的段落开始到 UITextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53402524/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com