在一个xib文件中的两个窗口之间传递数据? [英] Passing data between two window's in one xib file?
问题描述
Objective C和可可开发的新手,忙于玩一些写代码的应用程序只是为了练习,而我遇到了一些问题.
New to Objective C and cocoa developing, busy playing with some code writing app to just practice a bit, and I have a bit of a problem.
在其中装有一个窗口和一个HUB面板的xib中. HUB面板被隐藏,在窗口上有一个按钮,显示的是HUB,
Got a xib with a window and a HUB panel in it. The HUB panel is hidden, on the window there's a button, which diplay's the HUB with
[self.myHUBWindow orderFront.sender];
工作正常,然后在集线器上,我得到了一个文本字段和一个关闭HUB的按钮,关闭按钮也可以100%起作用:
works perfectly, then on the hub I got a text field and a button that close the HUB, close button, works 100% as well :
[self.myHUBWindow close];
我想做的是,当我单击主窗口上的按钮时,它应该在其中插入一些文本. HUB窗口上的文本字段.我有这个:
What I want to do is, when I click the button on the main window, it should insert some text into the text field on the HUB window. I have this :
[self.hubOutputTextField insertText:@"hello world"];
似乎什么都没发生:-/谁能指出我正确的方向?
Nothing seems to happen :-/ Can anyone point me in the right direction?
我的主窗口按钮IBAction:
My main window button IBAction :
- (IBAction)buildScannerButton:(id)sender {
[self.myHUBWindow orderFront:sender];
[self.hubOutputTextField insertText:@"hellow world"];
}
和我在文本字段中的@property
and my @property for the text field
@property (weak) IBOutlet NSTextField *hubOutputTextField;
推荐答案
尝试
[self.hubOutputTextField setStringValue:@"hello world"];
这篇关于在一个xib文件中的两个窗口之间传递数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!