如何使ChildViewController在相同的按钮操作上出现和消失

时间:2016-03-09 12:36:25

标签: ios objective-c xcode cocoa cocoa-touch

我正在使用childView控制器通过按钮在导航栏上显示一组选项/变种,当我点击按钮时,会出现子视图并在同一个按钮上单击我要删除子视图。 Plz帮助提前谢谢。

这是代码

UIViewController * topViewController = navigationControllerGlobal.topViewController; 
childViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil]instantiateViewControllerWithIdentifier:@"childViewStoryboardId"];
self.myParentViewController = topViewController;
[topViewController addChildViewController:childViewController] childViewController.view.frame= self.myParentViewController.view.frame ; 
[topViewController.view addSubview:childViewController.view]; 
[childViewController didMoveToParentViewController:topViewController];

1 个答案:

答案 0 :(得分:0)

这里是答案的人,

[[NSNotificationCenter defaultCenter] postNotificationName:@"removeChildNotify" object:navigationControllerGlobal.topViewController]