ios - 从 XIB 到 Storyboard

标签 ios xcode storyboard xib segue

我在 .xib 中获得了一个带有 Storyboard和一个窗口的应用程序。 从 Storyboard到 .xib,我以这种方式移动:

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

[self presentModalViewController:detailViewController animated:nil];

我怎样才能从 .xib 返回 Storyboard?

还有一个问题。从 Storyboard移动到 .xib 时,我可以发送一些信息吗?就像我在 prepareForSegue 方法中通过 segues

那样做

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

最佳答案

您只需关闭模态视图 Controller 即可返回 Storyboard。 像这样:

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

您应该将此方法放在您的 ShowDreamNIBController 中。 至于第二个问题,您可以通过使用委托(delegate)获取对模态视图 Controller 的引用,将信息发送回呈现模态视图 Controller 的 View Controller 。

编辑: “向 XIB 发送信息”是指将信息设置到要呈现的 View Controller 吗?如果是,则在呈现模态 Controller 时使用它:

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

希望对您有所帮助。

关于ios - 从 XIB 到 Storyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9190680/

相关文章:

ios - 什么是 WebKitErrorDomain 错误代码 204?

ios - 有没有办法在iOS应用程序崩溃时采取措施,从而执行代码?这可能吗?

iPhone - 设置 UIImage 位置

ios - Storyboard, self 展示 ViewController,iOS 6,空白屏幕

ios - 在容器 View ( Storyboard)内推送透明背景 UIViewController 时的灰色背景

ios - 单击时折叠和展开 UI

ios - NSPredicate swift2 的最长时间

xcode - 无法找到 `React-Core` 依赖的规范 `UMReactNativeAdapter`

iphone - 指向整数转换的不兼容指针将 'void *' 发送到类型为 'NSJSONReadingOptions' 的参数

ios - 在预定义属性之后设置用户定义的运行时属性(IBInspectable)?