We can use the UITextField’s delegate method
- (BOOL)textField: (UITextField *)textField shouldChangeCharactersInRange: (NSRange)range replacementString: (NSString *)string
to set the maximum character length.
This can be done by doing the following:
#define MAX_LENGTH 10
- (BOOL)textField: (UITextField *)textField shouldChangeCharactersInRange: (NSRange)range replacementString: (NSString *)string
{
if (textField.text.length >= MAX_LENGTH && range.length == 0)
{
return NO;
}
else
{
return YES;
}
}
|
Mac OS X software development is my bread winner with over 6 years of experience. Expertise in Color Management, TWAIN Scanner drivers on Mac OS X, Photoshop Filter and Import Plugin development on Mac OS X, iPhone. As an hobby I love to work on PHP, Flex, AIR, Photoshop. Check the 'About' page for more. |



