Created
September 2, 2014 15:40
-
-
Save zmcartor/2f8f06cf614c3c6b3267 to your computer and use it in GitHub Desktop.
TextField empty and filter out 'return' key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { | |
NSString *filteredString = [string stringByReplacingOccurrencesOfString:@"\n" withString:@""]; | |
NSInteger textLength = [textField.text length] - range.length + [filteredString length]; | |
if (textLength > 0) { | |
self.redeemButton.enabled = YES; | |
} | |
else { | |
self.redeemButton.enabled = NO; | |
} | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment