How can I set the maximum amount of characters in a UITextField
on the iPhone SDK when I load up a UIView
?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
To complete August answer, an possible implementation of the proposed function (see UITextField's delegate).
I did not test domness code, but mine do not get stuck if the user reached the limit, and it is compatible with a new string that comes replace a smaller or equal one.
Swift 3 version //***** This will NOT work with Swift 2.x! *****//
First create a new Swift file : TextFieldMaxLength.swift, and then add the code below:
and then you will see in Storyboard a new field (Max Length) when you select any TextField
if you still have more questions check out this link: http://www.globalnerdy.com/2016/05/18/ios-programming-trick-how-to-use-xcode-to-set-a-text-fields-maximum-length-visual-studio-style/
now how many characters u want just give values
Often you have multiple input fields with a different length.
This should be enough to solve the problem (replace 4 by the limit u want). Just make sure to add delegate in IB.
I simulate the actual string replacement that's about to happen to calculate that future string's length: