From XIB to Storyboard

流过昼夜 提交于 2019-12-05 01:33:13

问题


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];

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

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 I got answer about closing .xib. Need answer about sending information.


回答1:


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

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

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.

EDIT: 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];

I hope this helps.



来源:https://stackoverflow.com/questions/9190680/from-xib-to-storyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!