ios - Storyboard编辑器中的 "First Responder"和 "Exit"框的用途是什么?

标签 ios objective-c xcode cocoa responder-chain

在 XCode IDE 中,在 MainStoryboard 编辑器中 View Controller 的底部,有两个框:First Responder 和 Exit。

我知道代码中的 firstResponder 是什么,但在 Storyboard编辑器中,我似乎无法用它做任何有用的事情。

我能否使用该区域的第一响应者以某种方式设置 View 的第一响应者?我希望第一个文本字段在加载时处于事件状态,但我已尝试右键单击并拖动但无济于事。我知道我可以在 viewDidLoad 方法中以编程方式设置它,但是这里有什么方法可以做到吗?

绿色导出是做什么用的?

First Responder (orange) and Exit (Green) - what are they for?

最佳答案

这个问题没有好的答案,所以我贴出我的答案:

来自 here :

Note: You probably won’t be using the First Responder very much. This is a proxy object that refers to whatever object has first responder status at any given time. It was also present in your nibs and you probably never had a need to use it then either. As an example, you can hook up the Touch Up Inside event from a button to First Responder’s cut: selector. If at some point a text field has input focus then you can press that button to make the text field, which is now the first responder, cut its text to the pasteboard.

编辑:

1) 如果您使用带有键盘通知的文本字段,则 First Responder 非常有用。我用它来使键盘消失,为您的类(class)的变量 currentFirstResponder 创建一个导出,并在 viewWillDisappear 中:

[self.currentFirstResponder resignFirstResponder];

2) 您可以阅读有关 unwind segues(“退出”框)的信息 here

关于ios - Storyboard编辑器中的 "First Responder"和 "Exit"框的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13565128/

相关文章:

iphone - UIImageView 设置框架 : not working in UITableViewCell

ios - 在 iPhone 应用程序中保存图片

ios - 容器 View 转至相同大小的 View Controller

xcode - 无法转换类型的值,swift 2.0,错误处理

iOS v7.3.1 SpriteKit - For Loop Err Msg : Binary operator '..<' cannot be applied

ios - Appstore发布应用的神奇记录,核心数据迁移

java - NSArray 大小和可变性

ios - 在启动之前在拳头选项卡 View Controller 上加载数据

objective-c - OS X Core Data Utility 教程中的崩溃

ios - 我无法通过标签 objective-c 更改标签文本