ios - 呈现多个模态视图 Controller ?

标签 ios iphone objective-c uiviewcontroller presentmodalviewcontroller

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

我正在展示搜索 Controller ,它有 tableView 推送堆栈详细 Controller 。

详细 Controller 可以向 View Controller 呈现消息,它由小型 UIView 和半透明背景组成。

问题:当最后一个 View Controller 呈现时,它下面的所有 View Controller 都隐藏起来,而 Controller ,呈现的搜索 Controller 变得可见。

这是我在做什么:

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

比表推送详细 View :

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

和详细 View 呈现消息框:

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

当它被关闭时,它下面的所有 Controller 都变得可见。

更新:

我想要的只是以模态方式呈现一个将具有 uitableview 的 View Controller 。从此表显示详细 View ,将能够显示消息框。消息框必须是另一个 View Controller 。当显示消息框时,所有两个前面的 Controller 都会消失。这就是问题所在。

最佳答案

在某些情况下,您可以让每个模态呈现的 View Controller 呈现下一个 View Controller 。

let window = UIApplication.sharedApplication().keyWindow!
if let modalVC = window.rootViewController?.presentedViewController {
    modalVC.presentViewController(vc, animated: true, completion: nil)
} else {
    window.rootViewController!.presentViewController(vc, animated: true, completion: nil)
}

关于ios - 呈现多个模态视图 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19724166/

相关文章:

iphone - UISegmentedControl 放在 tableView 标题中时行为异常

objective-c - 使用文本字段添加两个数字

ios - 如何验证 ios 设备是否支持 Apple Pay

android - 更改 Firebase 项目中的所有者是否会更改其 google-service.json?

iphone - 如何检测 UITableView 中某个单元格的双击?

iphone - 如何使用xmpp框架仅列出facebook上的在线用户

Objective-c 类方法和复制返回值

objective-c - 垂直对齐 UINavigationItems

ios - 如何使用 dlsym 检查枚举值是否存在?

ios - 使用ePOS SDK打印图像