Objective c 在mailViewController中禁用横向模式
我在应用程序中使用以下代码禁用了横向模式:Objective c 在mailViewController中禁用横向模式,objective-c,ios,xcode,Objective C,Ios,Xcode,我在应用程序中使用以下代码禁用了横向模式: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } 但当邮件视图显示时,它会以某种
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
但当邮件视图显示时,它会以某种方式启用陆地景观模式
邮件操作代码:
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"Subject 1"];
UIImage *myImage = [UIImage imageNamed:@"logo_v22.png"];
NSData *imageData = UIImagePNGRepresentation(myImage);
[mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"mobiletutsImage"];
NSString *emailBody = @"Test ";
[mailer setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:mailer animated:YES];
}
主要问题:如何在mailView中禁用横向模式
附加问题:如何更改mailView中按钮的颜色?(取消按钮和发送按钮)您需要做的是将MFMailViewController子类化并覆盖其方向。这里有一个很好的例子:你只需要改变它以适应你想要的方向
编辑:这基本上是因为视图控制器在默认情况下启用了此模式,它不是从主视图控制器派生的,因此需要将其子类化我编辑了我的答案,以便为您提供更正确的解决方案。希望有帮助