gpt4 book ai didi

iOS - 从代码和 Storyboard推送 viewController

转载 作者:技术小花猫 更新时间:2023-10-29 10:40:44 27 4
gpt4 key购买 nike

我有这个代码

 PlaceViewController *newView = [self.storyboard instantiateViewControllerWithIdentifier:@"PlaceView"];
[self presentViewController:newView animated:YES completion:nil];

我可以更改 View ,但我会推送此 View ,因为当我返回此页面时,状态仍然存在。

我试着把这段代码:

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

但什么都不做。

谢谢

最佳答案

objective-C :

PlaceViewController *newView = [self.storyboard instantiateViewControllerWithIdentifier:@"storyBoardIdentifier"];
[self.navigationController pushViewController:newView animated:YES];

请注意以下几点,

  1. 您的 Storyboard标识符是正确的。

  2. Root View 有导航 Controller 。

swift :

let newView = self.storyboard?.instantiateViewController(withIdentifier: "storyBoardIdentifier") as! PlaceViewController
self.navigationController?.pushViewController(newView, animated: true)

关于iOS - 从代码和 Storyboard推送 viewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13987026/

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