开发者

textField:shouldChangeCharactersInRange:replacementString vs. UITextFieldTextDidChangeNotification

I'm building a Passcode Lock view, and I want to set the text to a dot on one of the four box labels when a user enters a new charact开发者_StackOverflower into the text field.

Should I use textField:shouldChangeCharactersInRange:replacementString or UITextFieldTextDidChangeNotification?

Using textField:shouldChangeCharactersInRange:replacementString seems easier, but shouldChangeCharactersInRange seems more correct.


I’d recommend using the delegate method, rather than the notification. Another option: set the text fields’ secureTextEntry property to YES. (See the documentation for the UITextInputTraits protocol, which UITextField conforms to).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜