Xcode 关闭视图控制器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16717250/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode close view controller
提问by w770115
I have two viewControllers parent and child, from parent I'm opening child viewController like this:
我有两个父视图控制器和子视图控制器,从父视图我打开子视图控制器是这样的:
ClildVC *modal = [[ClildVC alloc] initWithNibName:nil bundle:nil];
modal.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentModalViewController:modal animated:YES];
and when I return from child View to parent, I use this:
当我从子视图返回到父视图时,我使用了这个:
[self dismissModalViewControllerAnimated:YES];
I want, when returning to parent viewController it be refreshed (reloaded), like I open it first time.
我想要,当返回到父 viewController 时它被刷新(重新加载),就像我第一次打开它一样。
回答by Liolik
in your parentViewController in .h and .m add method
在 .h 和 .m 中的 parentViewController 中添加方法
- (void)refreshData
{
//refresh your data
}
in your childViewController type this
在你的 childViewController 中输入这个
- (IBAction)backToParent
{
YourParentController *parent = (YourParentController *)self.parentViewController;
[parent refreshData];
[self dismissModalViewControllerAnimated:YES];
}
回答by NoodleOfDeath
dismissModalViewControllerAnimated:
is deprecated as of iOS6
dismissModalViewControllerAnimated:
自 iOS6 起已弃用
You should use dismissViewControllerAnimated:completion:
which was introduced in iOS5 in the child view controller after calling a data update on its parent view controller
dismissViewControllerAnimated:completion:
在其父视图控制器上调用数据更新后,您应该在子视图控制器中使用 iOS5 中引入的
回答by John Jamieson
You are initiating with no nib file and no bundle identifier.
您是在没有 nib 文件和包标识符的情况下启动的。
So its looking for a non existent nib in a bundle that isn't there
所以它在一个不存在的包中寻找一个不存在的笔尖
either design the nib in IB (xcode 4) or storyboard (4.2 +) or programatically by using the designated initialiser for the modal view controller.
在 IB (xcode 4) 或 storyboard (4.2 +) 中设计笔尖,或者通过使用模式视图控制器的指定初始化程序以编程方式设计。