在故事板中使用 MFMailComposeViewController 不起作用
在故事板中,我可以设置从按钮到 UIViewController 的 Segue 并使其以模态方式显示。这很好用。但是,当我将故事板中的类从 UIViewController
更改为 MFMailComposeViewController
时,它根本不起作用。出现的只是顶部的导航栏,显示屏的其余部分填充为黑色。我采取了错误的方法吗?
In storyboard I can setup a segue from a button to a UIViewController
and make it appear modally. This works fine. However when I change the class in storyboard from UIViewController
to MFMailComposeViewController
, it does not work at all. All that appears is a navigation bar at the top with the rest of the display being filled with black. Am I taking the wrong approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在
ABPeoplePickerNavigationController
上遇到了类似的问题,而且我似乎也无法弄清楚问题是什么。您可以回退到
IBAction
并自行创建MFMailComposeViewController
实例并显示它。如果您想继续使用故事板(我认为这是可取的),那么您可以创建一个包装类,在内部实例化 MFMailComposeViewController ,然后充当代理对象,从而传播 viewDid *** 和
viewWill***
- 包装类的方法,并在只读view
属性中返回包装的 VC 视图...您得到想法。I had a similar problem with
ABPeoplePickerNavigationController
and I could not seem to figure out what the problem was either. You can eitherFall back to a
IBAction
and create theMFMailComposeViewController
instance your self and display it.If you want to keep using Storyboards, which I think is desirable then you might create a wrapper-class that internally instantiates the
MFMailComposeViewController
and then functions as a proxy object and thus propagatesviewDid***
andviewWill***
-methods to the wrapped class and also returning the wrapped VC's view in a readonlyview
property... You get the idea.除了 Besi 的回答之外:
MFMailComposeViewController
并覆盖initWithCoder:
方法。示例:
然后它将与故事板一起使用,但我认为故事板场景中的插座/标签/其他定义将不会应用(您必须在
prepareForSegue:sender:
方法中配置邮件编辑器)。In addition to the answer by Besi:
MFMailComposeViewController
and overrideinitWithCoder:
method.Example:
Then it will work with storyboards, but I think your outlets / tags / other definitions from storyboard scene won't be applied (you have to configure mail composer inside your
prepareForSegue:sender:
method).