Created
May 4, 2011 18:12
-
-
Save agiletalk/955696 to your computer and use it in GitHub Desktop.
UITextView Tutorial
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
// | |
// UITextViewTutorialViewController.h | |
// UITextViewTutorial | |
// | |
// Created by chanju Jeon on 11. 5. 4.. | |
// Copyright 2011 Talk on :Play. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
@interface UITextViewTutorialViewController : UIViewController <UITextViewDelegate> { | |
UITextView *textView; | |
UILabel *countLabel; | |
} | |
@property (nonatomic, retain) IBOutlet UITextView *textView; | |
@property (nonatomic, retain) IBOutlet UILabel *countLabel; | |
@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
// | |
// UITextViewTutorialViewController.m | |
// UITextViewTutorial | |
// | |
// Created by chanju Jeon on 11. 5. 4.. | |
// Copyright 2011 Talk on :Play. All rights reserved. | |
// | |
// 생략 | |
#pragma - Textview delegate | |
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { | |
// Any new character added is passed in as the "text" parameter | |
if([text isEqualToString:@"\n"]) { | |
// Be sure to test for equality using the "isEqualToString" message | |
[textView resignFirstResponder]; | |
// Return FALSE so that the final '\n' character doesn't get added | |
return FALSE; | |
} | |
// For any other character return TRUE so that the text gets added to the view | |
return TRUE; | |
} | |
- (void)textViewDidChange:(UITextView *)textView { | |
countLabel.text = [NSString stringWithFormat:@"%d", [textView.text length]]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment