MFMailComposeViewController 横向
我的应用程序处于横向模式。当我通过当前模型视图调用 MFMailComposeViewController 时,它处于横向模式。我旋转设备,MFMailComposeViewController 视图转到纵向模式,我想限制这种旋转,它应该始终仅处于横向模式。有没有方法来做到这一点..
My application is in landscape mod.When i call MFMailComposeViewController through Present model view, it comes in landscape mod.I rotate device and MFMailComposeViewController view goes to portrait mod i want to restrict this rotation it should always be in landscape mod only.Is there any way to do it..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
子类化 MFMailComposeViewController 类,以便您可以重写其 shouldAutorotateToInterfaceOrientation 以按照您喜欢的方式显示它:
指定新类代替 MFMailComposeViewController:
Subclass the MFMailComposeViewController class, so that you can override its shouldAutorotateToInterfaceOrientation to display it however you like:
Specify the new class in place of MFMailComposeViewController:
我发现 MFMailComposeViewController 的一个简单类别也有效。因为我喜欢我的应用程序旋转到任何角度,所以我创建了 &链接在 MFMailComposeViewController+Rotate.h:
和 MFMailComposeViewController+Rotate.m
出于我的基线测试目的(iOS 3.1.3),我似乎不需要将其放入根视图控制器中。
值得注意的是,在我这样做之前,在我的应用程序加载 MFMailComposeViewController 之后,即使在 MFMailComposeViewController 被解雇之后,它也会停止旋转到任何其他方向!现在我的应用程序仍然可以自由旋转。
I found that a simple category for MFMailComposeViewController also worked. Since I like my app to rotate to any angle, I created & linked in MFMailComposeViewController+Rotate.h:
and MFMailComposeViewController+Rotate.m
For my base line testing purposes (iOS 3.1.3), I don't seem to need to put it into the root view controller.
It is worth noting that BEFORE I did this, after my app would load MFMailComposeViewController, it would then stop rotating to any other orientation, even after MFMailComposeViewController was dismissed! Now my app remains freely rotatable.
这对我来说非常有效,只是做了一个小小的改变:
我确信我必须调用基类
initWithRootViewController
方法。否则,MFMailComposeViewController 如何知道它?但事实证明,上面的示例只需调用[[MailCompose alloc] init]
就足够了。底层 MFMailComposeViewController “只知道”如何显示自身。我喜欢这样的惊喜。我发布此内容是为了防止它对其他人同样具有启发性。
This worked for me, perfectly, with one minor change:
And I was convinced that I had to call the base-class
initWithRootViewController
method. Otherwise, how would the MFMailComposeViewController know about it? But it turns out the example above that simply calls[[MailCompose alloc] init]
is enough. The underlying MFMailComposeViewController "just knows" how to display itself.I love happy surprises like this. I posted this in case it is equally illuminating for anyone else.
创建一个新控制器并从 MFMailComposeViewController 继承它。在这个控制器中只需编写一个函数 shouldautorotate 即可。创建这个实例。现在它可以正常工作了。
Create a new controller and inherit it from MFMailComposeViewController.In this controller just write one function shouldautorotate thing. Create instance of this.Now it will be working fine.