[英]Check Number of Characters Of Textfield in SwiftUI
I am new to SwiftUI and I need to call a function when user enters minimum three characters in a textfield.我是 SwiftUI 的新手,当用户在文本字段中输入至少三个字符时,我需要调用function 。
Like this:像这样:
After completing three or more characters I want to perform a function. Is there any way to do this in SwiftUI ?完成三个或更多字符后,我想执行 function。有什么办法可以在SwiftUI中执行此操作吗?
You can use.onChange:你可以使用.onChange:
.onChange(of: name) { newValue in
if newValue.count >= 3 {
// Call function
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.