Objective c 如何仅旋转MFMailComposeViewController

Objective c 如何仅旋转MFMailComposeViewController,objective-c,cocoa-touch,rotation,mfmailcomposeviewcontroller,Objective C,Cocoa Touch,Rotation,Mfmailcomposeviewcontroller,我有一个应用程序,在iPod Touch/iPhone上不应该旋转。但是,我有一个MFMAIComoseviewcontroller供用户发送错误报告。但是,我的应用程序是如何设置的,没有任何东西可以旋转,这很好,除了这个单一视图。如何使其旋转到横向。它在一个类中声明,如下所示: // // LogbookSecondViewController.h // Logbook iDM // // Created by Josiah Bruner on 9/20/12. // Copyrigh

我有一个应用程序,在iPod Touch/iPhone上不应该旋转。但是,我有一个MFMAIComoseviewcontroller供用户发送错误报告。但是,我的应用程序是如何设置的,没有任何东西可以旋转,这很好,除了这个单一视图。如何使其旋转到横向。它在一个类中声明,如下所示:

//
//  LogbookSecondViewController.h
//  Logbook iDM
//
//  Created by Josiah Bruner on 9/20/12.
//  Copyright (c) 2012 Infinite Software Technologies. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>

@interface LogbookSecondViewController : UIViewController  <MFMailComposeViewControllerDelegate>
{
        MFMailComposeViewController *email;
}

@property (nonatomic, retain) MFMailComposeViewController *email;

@end

如何仅允许此视图旋转?谢谢。

创建您自己的类
MyCustomMailComposeViewController
(或任何扩展
MFMailComposeViewController
)。需要添加到此类的实现中的所有内容是:

// For iOS 6.0+
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

// For iOS 4.x and 5.x
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
这段代码假设您只需要邮件生成器的横向视图。如果需要所有方向,只需返回YES

然后改变:

email = [[MFMailComposeViewController alloc] init];
致:


创建您自己的类
MyCustomMailComposeViewController
(或任何扩展
MFMailComposeViewController
的类)。需要添加到此类的实现中的所有内容是:

// For iOS 6.0+
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

// For iOS 4.x and 5.x
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
这段代码假设您只需要邮件生成器的横向视图。如果需要所有方向,只需返回YES

然后改变:

email = [[MFMailComposeViewController alloc] init];
致:


是的,那可能就是我要做的。我希望有一些方法可以发送给MFMailComposeViewController,但我认为没有。谢谢你的帮助。是的,我可能会这么做。我希望有一些方法可以发送给MFMailComposeViewController,但我认为没有。谢谢你的帮助。