开发者

2 Action Connections in IB to one Button

I have an xcode app that I am building using IB for mac. THe app launches with windowA already opened. There is a button on WindowA that when pressed I would like to open WindowB and Consequently close WindowA.

I have found in the tutorials that there can only be 1 sent action connection per object, so all I can do at this point is have windowA clo开发者_StackOverflow社区se, or call WindowB to open on top.

Can anyone tell me how I can accomplish both using the same button?


Well, actually, you can call a single method. But within this method, you may accomplish several things. For example close a window and open another.

It's not necessary to create a complete class - which would correspond to a .m file. You just add another method

- (IBAction) doIt:(id) sender 

to an existing class file. Connect this to your button in IB. Therefore, you set "File's Owner" to the class where your IBAction is (or, better, put the IBAction method in "File's Owner" class file). In interface builder, select menu item File>Reload all class files Now, right click "File's Owner" in interface builder. You should see your action there. Drag the round circle on the right of the popup to your button. Now, each time your button is clicked, the method should be called.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜