iphone - 如何与标签进行通信(带有故事板的基于导航的应用程序)
我正在使用导航控制器制作一个应用程序,我已将其设置如下:
0-Navigation Controller -> 1-视图控制器(根视图)
1-视图控制器(根视图)-> 2-视图控制器(带有 SubViewController 类)#1
1-视图控制器(根视图)-> 2-视图控制器(带有 SubViewController 类)#2
1-视图控制器(根视图)-> 2-View 控制器(带有 SubViewController 类)#3
1-View 控制器包含一个文本字段、UILabel
和 3 个按钮: 按钮 #1 转到 2-ViewController #1、#2 到 #2、#3 到 #3,使用 segue
的(push)来连接按钮和视图控制器之间。
如果这还不清楚,我会解释一下:如果您在 1-ViewController 中按下按钮 #1,您将转到 SubViewController #1。
现在我陷入困境: 我想与 SubViewController 中的标签进行通信,但我无法从该 UILabel 到任何地方绘制一条蓝线(CTRL 拖动)...(ViewController 除外,它提供了选项:view,这似乎并不我想我需要什么)。
我想要发生的事情: 用户在 1-ViewController 的文本字段中输入数据,然后该数据将显示在所选 2-SubViewController 的 UILabel
中。
我该怎么做?
编辑:
我的助理编辑器似乎被设置为手动而不是自动。切换回来后,我就可以拖线了。
I am making an app using a Navigation Controller, which I've set up like this:
0-Navigation Controller -> 1-View Controller (Root View)
1-View Controller (Root View) -> 2-View Controller (with class SubViewController) #1
1-View Controller (Root View) -> 2-View Controller (with class SubViewController) #2
1-View Controller (Root View) -> 2-View Controller (with class SubViewController) #3
1-View Controller contains a Text Field, UILabel
, and 3 Buttons:
button #1 goes to 2-ViewController #1, #2 to #2, #3 to #3, using segue
's (push) for the connections between the buttons and viewcontrollers.
If this isnt clear, I'll explain: If you press button #1 in 1-ViewController, you go to SubViewController #1.
Now where I'm getting stuck:
I want to communicate with a label in the SubViewController, but I can't draw a blue line (CTRL drag) from that UILabel to anywhere... (except the ViewController, which then gives the option: view, which doesn't seem what I need, I think).
What I want to happen:
The user enters data in the textfield in 1-ViewController, which then is displayed in the UILabel
in the chosen 2-SubViewController.
How can I do this?
EDIT:
It seems that my Assistant Editor was set to Manual instead of Automatic. After switching back, I was able of dragging lines.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您必须手动执行此操作:
在应处理标签的
UIViewController
中为UILabel
添加一个IBOutlet
:您现在将拥有Interface Builder 中的选项可将标签从标签拖动到相应的
UIViewController
。You'll have to do it manually:
add an
IBOutlet
for theUILabel
in theUIViewController
that should handle the label:you'll now have the option in Interface Builder to drag from your label to the corresponding
UIViewController
.