我正在开发一个照片预览组件。现在我遇到了显示 modalViewController 的问题:当我想显示预览 View 时,我正在做的是这样的:
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
EKImageViewer *viewer = [[EKImageViewer alloc] initWithFrame:frame];
[window addSubview:viewer];
[window addSubview:viewer.preview];
[window addSubview:viewer.shareBtn];//A UIButton control
关闭预览 View 时,我正在做的是这样的:
[viewer.shareBtn removeFromSuperview];
[viewer.preview removeFromSuperview];
[viewer removeFromSuperview];
当点击预览组件中的 shareBtn(UIButton) 时,我想显示模态视图(MFMailComposeViewController):
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentModalViewController:controller animated:YES];
发生了一些奇怪的事情:modalViewController 显示在预览组件下。只有当我关闭预览组件时,我才能看到modalViewController。我有什么错吗?
最佳答案
不要在窗口
顶部添加查看器
。相反,添加您的 rootViewController.view。
这应该可以解决这个问题。如果可能的话,尽量不要在 window
上添加除 rootViewController
之外的任何内容。之后您想添加的任何内容都可以添加到 rootViewController
上。
关于ios - ModalViewController 隐藏在 View 下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13814527/