ios – 呈现多个视图控制器?

前端之家收集整理的这篇文章主要介绍了ios – 呈现多个视图控制器?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
更新:
我再次面临这个问题,并找到另一种方式.如果演示控制器没有嵌入到导航控制器中,如果控制器不是全屏显示,它将被隐藏,并且会变黑.方法setModalPresentationStyle:UIModalPresentationCurrentContext只能应用于导航控制器.因此,在UINavigationController中嵌入呈现控制器,将UIModalPresentationCurrentContext设置为新的控制器 – 您将获得对话控制器.

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

详细的控制器可以显示带有消息的视图控制器,它由小的UIView和半透明背景组成.

问题:当最后一个视图控制器出现时,它下面的所有视图控制器变得隐藏,并且显示搜索控制器的控制器变得可见.

在这里我在做什么

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];

和详细视图介绍消息框:

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

当它被解雇时,其下的所有控制器变得可见.

更新:

所有我想要的是以模态的方式呈现一个视图控制器,它将具有可视性.从这个表中可以看到详细的视图,可以显示消息框.消息框必须是另一个视图控制器.当显示消息框时,所有两个前面的控制器消失.这是问题.

解决方法

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.

http://xissburg.com/presenting-multiple-modal-view-controllers-at-once/

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

猜你在找的iOS相关文章