objective-c - 将事件连接到 UITextView

标签 objective-c iphone events uitextview

我似乎无法将事件连接到我的 UITextView。

期待可用于 UITextField 的事件列表(“Did End On Exit”、“Editing Changed”等)应该都可用于 UITextView。

然而事实并非如此。 UITextView 在其事件列表中显示什么

这是怎么回事,我如何捕获 UITextView 的事件?

最佳答案

您的 View Controller 需要实现 UITextViewDelegate。

@interface SaveGameViewController : UIViewController<UITextViewDelegate>  

将 UITextViewDelegate 添加到 View Controller 后,打开 Interface Builder,您可以在 First Owner 下找到这个“委托(delegate)” Hook 。

在我的例子中,我在 SaveGameView 中有一个 TextView ,它是 SaveGameViewController 的 View ,当在 IB 中打开我的 SaveGameViewController.xib 时,我可以将 TextView 连接到 First Owner 中委托(delegate),以便 View Controller 响应到委托(delegate)事件:

-(IBAction)textViewDidBeginEditing:(UITextView *)textView;

这个方法也在SaveGameViewController中

关于objective-c - 将事件连接到 UITextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1784796/

相关文章:

ios - 使用 .txt 文件在 iOS 中存储数据?

javascript - 如何检查事件传播是否停止?

jquery - 删除子项的事件处理程序

javascript - 是否有用于 jQuery 的移动触摸事件插件?

ios - 在 IOS 中将包含 NSDictionary 对象的 NSArray 转换为单个 NSDictionary

ios - 多次点击 UIButton 多次触发 Target 函数

ios - 保存一个UIImage并在UIImageview上重用

iphone - IOS:生物体的内存问题和

objective-c - 删除分组的 UITableView 中的顶部阴影?

objective-c - objective-c : Reading text files