呈现多个模态视图控制器? [英] Present multiple modal view controllers?

查看:23
本文介绍了呈现多个模态视图控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:
我再次遇到了这个问题,并找到了另一种方法.如果呈现控制器没有嵌入到导航控制器中,如果呈现控制器不是全屏显示,它将被隐藏并变为黑色.方法 setModalPresentationStyle:UIModalPresentationCurrentContext 只能应用于导航控制器.因此,在 UINavigationController 中嵌入呈现控制器,将 UIModalPresentationCurrentContext 设置为它并呈现新的控制器 - 您将获得对话框控制器.

update:
I've faced this problem again, and found another way. If presenting controller is not embedded in navigation controller, it will be hidden if presented controller is not fullscreen and will became black. Method setModalPresentationStyle:UIModalPresentationCurrentContext can be applied only to navigation controller. So embed presenting controller in UINavigationController, set UIModalPresentationCurrentContext to it and present new controller - you will get dialog controller.

我正在展示搜索控制器,它具有推送堆栈详细控制器的 tableView.

I'm presenting search controller, it have tableView that push on stack detailed controller.

详细的控制器可以将消息呈现给视图控制器,它由小的 UIView 和半透明的背景组成.

Detailed controller can present view controller with message, it consists from small UIView and semitransparent background.

问题:当最后一个视图控制器呈现时,它下的所有视图控制器都隐藏起来,控制器,呈现的搜索控制器变得可见.

Problem: when last view controller presented, all view controllers under it becomes hidden and controller, that presented search controller becomes visible.

这是我在做什么:

SearchViewController *viewController = [[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];
viewController.data = dataArray;

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self.navigationController setModalPresentationStyle:UIModalPresentationCurrentContext];
[self.navigationController presentViewController:navigationController animated:YES completion:nil];

比表推送详细视图:

DetailViewController *viewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
[viewController setHidesBottomBarWhenPushed:YES];
viewController.dataItem = [data objectAtIndex:(NSUInteger) [indexPath row]];
[self.navigationController pushViewController:viewController animated:YES];

和显示消息框的详细视图:

and detailed view presenting message box:

MessageController *controller = [[MessageController alloc] initWithNibName:@"MessageController" bundle:nil];
controller.message = message;
[self presentViewController:controller animated:YES completion:nil];

当它被关闭时,它下的所有控制器都变得可见.

When it's dismissed, all controllers under it became visible.

更新:

我想要的只是模态地呈现一个具有 uitableview 的视图控制器.从这个表显示详细视图,将能够显示消息框.消息框必须是另一个视图控制器.当消息框显示时,所有两个前面的控制器都消失了.这就是问题所在.

all I wanted is to present modally a view controller that will have uitableview. From this table to show detailed view that will be able to show message box. Message box must be another view controller. And when message box is shown all two preceding controllers disappears. that is the issue.

推荐答案

尝试实现这一目标的简单方法就是创建 VC您想以模态呈现并一个接一个呈现.不幸的是,这行不通.你得到的只是第一个VC 提出,所有其他人都无处可去.UIKit 就是不合作和你在一起.

The trivial way to attempt to achieve that is to just create the VCs you want to present modally and present one after the other. Unfortunately, this is not gonna work. What you get is just the first VC presented, all others just go nowhere. UIKit just won’t cooperate with you here.

UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

这篇关于呈现多个模态视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆