微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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();

原文地址:https://www.jb51.cc/iOS/330431.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐