xcode UITextView 结束编辑

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12925579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:50:42  来源:igfitidea点击:

UITextView did end editing

iphoneobjective-cxcodetextviewuitextview

提问by atomikpanda

I would like to NSLogsomething when my UITextView is done editing.

NSLog当我的 UITextView 完成编辑时,我想要一些东西。

I've tried

我试过了

- (BOOL)textViewShouldEndEditing:(UITextView *)textView

- (BOOL)textViewShouldEndEditing:(UITextView *)textView

and

- (void)textViewDidEndEditing:(UITextView *)textView

- (void)textViewDidEndEditing:(UITextView *)textView

neither worked.

都没有工作。

fix:

使固定:

myTextView.delegate = self;

myTextView.delegate = self;

回答by LianYong Lee

do you set the delegate of your textview?

你设置你的textview的代表吗?

fix:

使固定:

set delegate in .h file like this:

在 .h 文件中设置委托,如下所示:

#import <UIKit/UIKit.h>  

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

回答by Zeezer

If you are using UITextField instead make sure to use UITextFieldDelegate and not UITextViewDelegate. And this method instead, that fixed my problems.

如果您使用 UITextField,请确保使用 UITextFieldDelegate 而不是 UITextViewDelegate。而这种方法却解决了我的问题。

- (void)textFieldDidEndEditing:(UITextField *)textField