2010-11-07 41 views

回答

14

落實UITextViewDelegate方法稱爲textViewDidBeginEditing:,並且在它的內部,在text屬性設置爲空NSString對象:

- (void) textViewDidBeginEditing:(UITextView *) textView { 
    [textView setText:@""]; 
    //other awesome stuff here... 
} 
+3

+1提供空間,把 「真棒東西」。 – 2010-11-07 22:28:48

+0

不適用於我,實施委託,添加此方法,但它不會因爲某些原因不明。 – 2014-02-21 17:02:26

0

上面並沒有爲我工作,只好用通知:

加通知在視圖上出現:

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textViewDidBeginEditing:) name:UITextViewTextDidBeginEditingNotification object:nil]; 

清除當前tex的方法牛逼視圖

-(void)textViewDidBeginEditing:(NSNotification *)notif{ 
UITextView *textView=notif.object; 
[email protected]""; 

}

移除通知在viewWillDisappear:

[[NSNotificationCenter defaultCenter] removeObserver:self name:UITextViewTextDidBeginEditingNotification object:nil]; 

希望它可以幫助別人

相關問題