从XIB到Storyboard [英] From XIB to Storyboard

查看:109
本文介绍了从XIB到Storyboard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有故事板的应用程序和.xib中的一个窗口。
从故事板到.xib我以这种方式移动:

I got an app with a storyboard and one window in .xib. From the storyboard to the .xib i move in that way:

ShowDreamNIBController *detailViewController = [[ShowDreamNIBController alloc] initWithNibName:nil bundle:nil];

[self presentModalViewController:detailViewController animated:nil];

如何从.xib回到故事板?

How can i move back from the .xib to the storyboard?

还有一个问题。从故事板移动到.xib时,我可以发送一些信息吗?就像我在 prepareForSegue 方法中的segt一样。

And one more question. Can i send some information when move to the .xib from storyboard? Like i do it throught segues in prepareForSegue method

UPD 我得到了关于关闭的答案的.xib。需要回答有关发送信息的信息。

UPD I got answer about closing .xib. Need answer about sending information.

推荐答案

您只需关闭模态视图控制器即可返回故事板。
喜欢这个:

you can get back to your storyboard by simply dismissing the modal view controller. Like this:

- (IBAction)backPressed:(id)sender {
    [self dismissModalViewControllerAnimated:YES];
}

您应该将此方法放在ShowDreamNIBController中。
至于第二个问题,你可以通过使用委托来引用模态视图控制器,向视图控制器发回信息。

You should put this method in your ShowDreamNIBController. As for the second question, you can send back information to the view controller that presented the modal view controller by getting reference to it using delegation.

编辑:
要向XIB发送信息,是否要将信息设置到要显示的视图控制器?如果是,请在呈现模态控制器时使用它:

To "send information to the XIB" do you mean that you want to set information to the view controller that you want to present? If yes, than use this when you present the modal controller:

ShowDreamNIBController *detailViewController = [[ShowDreamNIBController alloc]initWithNibName:nil bundle:nil];
[detailViewController setSomething: something];
[detailViewController setAnotherThing: anotherThing];
[self presentModalViewController:detailViewController animated:nil];

我希望这有帮助。

这篇关于从XIB到Storyboard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆