@protocol CommentTextViewDelegate;
@interface CommentTextView : UIView <UITextViewDelegate>{
id<CommentTextViewDelegate> _delegate;
UITextView *cTextView;
UIView *placeHolderView;
UIButton *submitButton;
}
@property (nonatomic, assign) IBOutlet id<CommentTextViewDelegate> delegate;
@property (nonatomic, retain) UITextView *cTextView;
@property (nonatomic, retain) UIView *placeHolderView;
@property (nonatomic, retain) UIButton *submitButton;
- (id) init;
- (id) initWithCoder:(NSCoder *)aDecoder;
- (id) initWithFrame:(CGRect)frame;
- (NSString*) submitComment;
@end
@protocol CommentTextViewDelegate <NSObject>
@optional
- (BOOL)shouldSubmitCommentTextButton:(NSString *)commentText;
@end
#import "CommentTextView.h"
@implementation CommentTextView
@synthesize delegate = _delegate;
- (NSString*) submitComment{
BOOL reVal = YES;
NSString *str = [cTextView text];
if ([_delegate respondsToSelector:@selector(shouldSubmitCommentTextButton:)]) {
reVal = [_delegate shouldSubmitCommentTextButton:str];
}
if (reVal) {
[cTextView resignFirstResponder];
[cTextView setText:@""];
if (target) {
[target performSelector:selector withObject:str];
}
}
return str;
}
- (BOOL)submitCommentTextButton:(NSString *)commentText{
if(...){
return YES;
}else {
return NO;
}
}
'Computer' 카테고리의 다른 글
iPhone http client API (NSURLConnection) - 1 (0) | 2010.05.31 |
---|---|
iPhone user Agent (0) | 2010.05.25 |
iPhone - Delegate 만들기 - 1 (0) | 2010.05.25 |
iPhone NSUserDefaults 사용하기 (0) | 2010.05.25 |
iPhone Property list - info.plist 에 추가하는 Property (0) | 2010.05.24 |