我正在使用以下代码从UIViewController
调用“HelpviewController”,该代码正常运行。
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"InnerHelpPageViewController"];
self.pageViewController.dataSource = self;
InnerHelpViewController *startingViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
// Change the size of page view controller
self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 30);
[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
在我的新控制器InnerHelpViewController
内部,我已完成按钮,该按钮应删除此新添加的视图并将控制权发送回已启动的页面。
- (IBAction)unwindToMenuFromInnerHelp:(id)sender {
[self.view removeFromSuperview];
}
此调用删除了新添加的视图,但问题是“MenuController”被冻结。我无法点击它。有什么帮助吗?
解释流程 - >我有菜单屏幕,其中一个按钮名称为“help” - >当用户点击此帮助按钮时,此问题中的第一段代码执行并显示HelpViewController - >完成帮助后,用户点击“完成”按钮 - >哪个应该关闭HelpViewController并移动到“菜单”屏幕。
答案 0 :(得分:1)
在InnerHelpViewController.h文件类中实现协议方法
@protocol InnerHelpViewControllerDelegate
-(void)removeCustomView;
@end
@interface InnerHelpViewController : UIViewController{
}
@property(nonatomic, weak) id<InnerHelpViewControllerDelegate> delegate.
在InnerHelpViewController.m文件中
@synthesize delegate;
- (IBAction)unwindToMenuFromInnerHelp:(id)sender {
[delegate removeCustomView];
}
MenuController .h文件中的采用InnerHelpViewControllerDelegate。
@interface MenuController : UIViewController<InnerHelpViewControllerDelegate>{
}
现在在helpviewcontroller对象创建时在MenuController.m文件中确认您的委托。
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"InnerHelpPageViewController"];
self.pageViewController.dataSource = self;
InnerHelpViewController *startingViewController = [self viewControllerAtIndex:0];
startingViewController.delegate = self;
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
// Change the size of page view controller
self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 30);
[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
//Implement here delegate method
-(void)removeCustomView{
[self.pageViewController removeFromSuperview]
}