iOS - 从代码和故事板推送 viewController [英] iOS - Push viewController from code and storyboard
本文介绍了iOS - 从代码和故事板推送 viewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个代码
PlaceViewController *newView = [self.storyboard instantiateViewControllerWithIdentifier:@"PlaceView"];
[self presentViewController:newView animated:YES completion:nil];
并且我可以更改视图,但是当我返回此页面时,我会推送此视图,状态仍然存在.
And I can change view, but I would push this view for when I return at this page, the state persists.
我试着把这个代码:
[self.navigationController pushViewController:newView animated:YES];
但什么都不做.
谢谢
推荐答案
Objective-C:
PlaceViewController *newView = [self.storyboard instantiateViewControllerWithIdentifier:@"storyBoardIdentifier"];
[self.navigationController pushViewController:newView animated:YES];
请注意以下几点,
您的故事板标识符正确.
your storyboard identifier is correct.
根视图有导航控制器.
斯威夫特:
let newView = self.storyboard?.instantiateViewController(withIdentifier: "storyBoardIdentifier") as! PlaceViewController
self.navigationController?.pushViewController(newView, animated: true)
这篇关于iOS - 从代码和故事板推送 viewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文