【问题标题】:How to present a modal view controller on the iphone without a "current" view controller?如何在没有“当前”视图控制器的情况下在 iphone 上呈现模态视图控制器?
【发布时间】:2026-02-13 01:00:01
【问题描述】:

我正在尝试打开电子邮件视图控制器 (MFMailComposeViewController),我阅读的所有内容都建议使用 presentModalViewController:animated:,这似乎需要发送到 UIViewController

例如,在the documentation 中,它说:

调用当前视图控制器的presentModalViewController:animated:方法,传入你要模态呈现的视图控制器。

但我没有“当前视图控制器”!我的应用程序完全是 OpenGL,我的设置代码如下所示:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.view = [[IPhoneView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

[window addSubview: self.view];
[window makeKeyAndVisible];

我在 IPhoneView 类中设置了 OpenGL 上下文。

我发现许多questions 询问如何从UIView 获得UIViewController,而共识似乎是:不要。那么如何使用漂亮的滑动动画打开电子邮件视图控制器呢?

【问题讨论】:

    标签: iphone uiview uiviewcontroller mfmailcomposeviewcontroller


    【解决方案1】:

    您始终可以制作自己的视图滑动动画,只需将 MFMailComposeViewController 传递给它:Hidden Drawer example

    在这里也可以看到类似的滑动代码:How can I present a UIView from the bottom of the screen like a UIActionSheet?

    【讨论】:

      最近更新 更多