问题描述
我的应用程序处于风景模式,当我通过Present模型视图调用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..
推荐答案
子类化MFMailComposeViewController类,以便您可以覆盖它的shouldAutorotateToInterfaceOrientation来显示它,但是您喜欢:
Subclass the MFMailComposeViewController class, so that you can override its shouldAutorotateToInterfaceOrientation to display it however you like:
@interface MailCompose : MFMailComposeViewController {
}
@end
@implementation MailCompose
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
@end
指定新类代替MFMailComposeViewController:
Specify the new class in place of MFMailComposeViewController:
MailCompose *controller = [[MailCompose alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"In app email..."];
[controller setMessageBody:@"...email body." isHTML:NO];
[self presentModalViewController:controller animated:YES];
[controller release];
这篇关于横向中的MFMailComposeViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!