Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 09-17-2009, 03:03 PM   #4 (permalink)
alexstuckey
Registered Member
 
Join Date: Aug 2009
Posts: 23
alexstuckey is on a distinguished road
Default

Quote:
Originally Posted by MarkC View Post
Elaborating a bit on the above, here's a piece of code that'll limit the length for you Alex, as well as stopping you entering %, & and ". Define kmaxCharacters in the header...

Code:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
	if (textField.text.length >= kmaxCharacters && range.length == 0)
	{
		return NO; // return NO to not change text
	}else{
		if ([string isEqualToString:@"\""] || [string isEqualToString:@"-"] || [string isEqualToString:@"%"] ) {
			return NO;
		}
		return YES;
	}
}
Thank you for that, I tried to put it in but I don't know which file it goes in and/or if I have to do any linking between the UITextField and the code.
alexstuckey is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,277
Threads: 93,954
Posts: 402,303
Top Poster: BrianSlick (7,971)
Welcome to our newest member, AppTroll
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:42 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.