2012-10-17 80 views
4

我想NSLog當我的UITextView完成編輯時。UITextView沒有結束編輯

我已經試過

- (BOOL)textViewShouldEndEditing:(UITextView *)textView

- (void)textViewDidEndEditing:(UITextView *)textView

既不工作。

修復:

myTextView.delegate = self;

回答

10

你設置你的TextView的代表?

的解決辦法:在.h文件中

組代表這樣的:

#import <UIKit/UIKit.h> 

@interface TextViewController : UIViewController <UITextViewDelegate> 
{ 
      UITextView *textView; 
} 
@property (nonatomic, retain) UITextView *textView; 
@end 
+0

我會接受你的答案,當它讓我。感謝您的快速回復。 – atomikpanda

+0

並且不要忘記.h文件中的代理設置 –

+0

如何在.h文件中設置它? – atomikpanda

2

如果您正在使用的UITextField,而不是一定要使用UITextFieldDelegate而不是UITextViewDelegate。而這種方法反而改變了我的問題。

- (void)textFieldDidEndEditing:(UITextField *)textField