gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:06:22 26 4
gpt4 key购买 nike

听说在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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com