Created
October 24, 2012 05:08
-
-
Save ChrisRisner/3944063 to your computer and use it in GitHub Desktop.
ios Day 9
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)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { | |
if (textView == self.txtView) { | |
NSInteger newTextLength = [textView.text length] - range.length + [text length]; | |
if (newTextLength > 45) { | |
return NO; | |
} | |
} | |
return YES; | |
} |
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) textFieldShouldEndEditing:(UITextField *)textField { | |
if (textField == self.txtFieldOne && | |
[textField.text isEqualToString:@"done"]) { | |
return NO; | |
} | |
return YES; | |
} |
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
@interface ViewController : UIViewController <UITextViewDelegate, UITextFieldDelegate> | |
@property (weak, nonatomic) IBOutlet UITextField *txtFieldOne; | |
@property (weak, nonatomic) IBOutlet UITextField *txtFieldTwo; | |
@property (weak, nonatomic) IBOutlet UITextView *txtView; | |
@property (weak, nonatomic) IBOutlet UIButton *btnButton; | |
- (IBAction)tappedButton:(id)sender; | |
@end |
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
- (void)textFieldDidBeginEditing:(UITextField *)textField { | |
if (textField == self.txtFieldOne) { | |
textField.text = @"Don't edit me!"; | |
} | |
} |
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) textFieldShouldBeginEditing:(UITextField *)textField { | |
if (textField == self.txtFieldTwo && | |
[textField.text isEqualToString:@"No Change"]) { | |
return NO; | |
} | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment