在 XCode IDE 中,在 MainStoryboard 编辑器中 View Controller 的底部,有两个框:First Responder 和 Exit。
我知道代码中的 firstResponder 是什么,但在 Storyboard编辑器中,我似乎无法用它做任何有用的事情。
我能否使用该区域的第一响应者以某种方式设置 View 的第一响应者?我希望第一个文本字段在加载时处于事件状态,但我已尝试右键单击并拖动但无济于事。我知道我可以在 viewDidLoad 方法中以编程方式设置它,但是这里有什么方法可以做到吗?
绿色导出是做什么用的?
最佳答案
这个问题没有好的答案,所以我贴出我的答案:
来自 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/