iphone - instantiateViewControllerWithIdentifier 显示空白 View (xcode 4.5)

标签 iphone ios storyboard ios6

听说在XCode 4.5中有一些变化,Storyboard identifier不再叫identifier,而是Storyboard ID。我尝试使用它,但它没有启动任何东西。它总是空白的。我做错了什么?

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];

 HistoryViewController* historyVC = [storyboard instantiateViewControllerWithIdentifier:@"histSB"];

  [self presentViewController:historyVC animated:YES completion:nil];

 [self.navigationController pushViewController:historyVC animated:YES];

 [self presentModalViewController:historyVC animated:YES];

查看 Storyboard中设置的屏幕截图:

enter image description here

最佳答案

这是我在我的应用程序中使用过几次的东西,用于那些 segues 不切实际的地方。根据上面提供的代码和屏幕截图,以下是我的连接方式:

HistoryViewController *historyVC = [self.storyboard instantiateViewControllerWithIdentifier: @"histSB"];
[self.navigationController pushViewController: historyVC animated:YES];

如果您从 iPad 上的弹出窗口显示 View Controller ,这将特别有用。将带有自己的导航 Controller 的 View 添加到 Storyboard:

enter image description here

请注意,导航 Controller 左侧没有 segue。以下代码在弹出窗口中显示此内容:

HistoryViewController *historyVC = [self.storyboard instantiateViewControllerWithIdentifier: @"histSB"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: historyVC];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController: navigationController];

然后,您可以以此为基础,通过 segue(注意 View Controller 右侧的那个)将其他 View Controller 推送到导航 Controller 上:

[self performSegueWithIdentifier: @"WhateverComesNextSegue" sender: self];

希望对您有所帮助。

关于iphone - instantiateViewControllerWithIdentifier 显示空白 View (xcode 4.5),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12843815/

相关文章:

iphone - UITableView 幻灯片不可编辑行与可编辑行 Xcode iPhone

ios - Cocoapods: 没有这样的模块 'CorePlot'

ios - 从 Storyboard修改定制的单元格

iphone - AVCaptureSession 运行时显示相机流

iphone - Objective-C 和 ASIHTTPRequest - 响应字符串问题

iphone - 将 SDNestedTable 添加到 subview

ios - 在隐藏的导航栏上具有不同行为的 ViewController

ios - 在使用 Objective - C 制作的 App 中使用 Swift 代码

ios - 设置单元格圆角和边框宽度使表格 View 滚动速度极慢

ios - 适合屏幕 iOS 上的所有对象