Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UIAlertView文本视图中的Xcode ios限制字符_Ios_Xcode_Uitextview - Fatal编程技术网

UIAlertView文本视图中的Xcode ios限制字符

UIAlertView文本视图中的Xcode ios限制字符,ios,xcode,uitextview,Ios,Xcode,Uitextview,我看过很多关于这方面的教程,但都是针对Objective C的。我想在我的应用程序中实现这一功能,但不知道如何实现。 任何帮助都是伟大的 import UIKit class ViewController: UIViewController, UITextFieldDelegate { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the v

我看过很多关于这方面的教程,但都是针对Objective C的。我想在我的应用程序中实现这一功能,但不知道如何实现。 任何帮助都是伟大的

import UIKit

class ViewController: UIViewController, UITextFieldDelegate {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    let alert = UIAlertView(title: "Client id", message: "some title", delegate: self, cancelButtonTitle: "ok")
     alert.alertViewStyle = .plainTextInput

    let textField: UITextField = alert.textField(at: 0)!
    textField.delegate = self

    alert.show()
}
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
    if (textField.text?.characters.count)! < 10
    {
        return true
    }
    return false
}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

这种宽泛的告诉我如何提问并不适合堆栈溢出。如果你找到了一些教程,解释了如何使用Objective-C实现你的目标,那么看看你是否能够记录下你认为他们在做什么,并尝试在Swift中实现同样的事情。如果你不能,回来,发布一个链接到你正在学习的教程,展示你写的代码,告诉我们你的代码出了什么问题,然后我们可以帮助你。