i have a UIView with 10 UITextFields on it.i want to limit the different max character length on each UItextField.suppose on the first textfield the max length should be 17,for second and third it should be 2.how do i achieve this?
views:
303answers:
1
+1
A:
Implement a UITextViewDelegate
with textView:shouldChangeTextInRange:replacementText
and return NO
when the length of the text view's content is equal to or greater than the maximum length. The only exception to this is when the replacementText
is empty in which case you should always return YES
freespace
2009-05-23 07:05:30
i have already implemented the method you mention above but it max limit is same for all uitextfields.i want different for different textfields
Rahul Vyas
2009-05-23 08:31:38
You can either use a different delegate for each text view, or use the same delegate but differentiate between different text views
freespace
2009-05-23 12:11:58
how do i do this mean use the same delegate but differentiate between different text views
Rahul Vyas
2009-05-23 15:26:05
Store pointers to each text view somewhere, when the function is called the text view which triggered the method is passed in. Compare the passed in pointer against the pointers you have and determine which character limit you need to apply.
freespace
2009-05-23 16:10:56
could you please post a sample code
Rahul Vyas
2009-05-25 10:19:59
post your attempts at implementing my answer.
freespace
2009-05-25 16:06:04