2

iPod Touch/iPhoneで回転しないアプリケーションがあります。ただし、ユーザーがバグレポートを送信するためのMFMaiComposeViewControllerがあります。私のアプリの設定方法では、回転することはできません。これは、この単一のビューを除いて問題ありません。これを横向きに回転させるにはどうすればよいですか。これは、次のように1つのクラスで宣言されます。

//
//  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

.mで

- (IBAction)sendEmail:(id)sender {
    NSLog(@"ToolsController - Send Email");
    NSString *MailTO = @"infinite@qualityservice.com";
    email = [[MFMailComposeViewController alloc] init];
    email.mailComposeDelegate = self;
    NSArray *recipitants = [NSArray arrayWithObject:MailTO];
    // Subject
    [email setSubject:@"Bug/Problem/Suggestion, Logbook iDM"];

    [email setToRecipients:recipitants];

    // Present it
    [email setModalPresentationStyle:UIModalPresentationFormSheet];
    [email setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
    [self presentViewController:email animated:YES completion:nil];
}


- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
    [email dismissViewControllerAnimated:YES completion:nil];

}

このビューのみを回転させるにはどうすればよいですか?ありがとう。

4

1 に答える 1

4

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];

に:

email = [[MyCustomMailComposeViewController alloc] init];
于 2013-01-12T20:30:52.687 に答える