How can I display mail composer in landscape mode by using MFMailComposeViewController in cocos2d?

I am writing a game in cocos2d. I want to add MFMailComposeViewController to the scene. So, when I touch a CcLabel in the scene the mail sheet is opened.

@interface EmailScene : CCScene <MFMailComposeViewControllerDelegate>
    MFMailComposeViewController *picker;



@implementation EmailScene

- (id) init {

    self = [super init];
    if (self != nil) {
        [self displayComposerSheet];
    return self;

    [[CCDirector sharedDirector] pause];
    picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    NSArray *toRecipients = [NSArray arrayWithObject:@""]; 
[picker setToRecipients:toRecipients];

    [[[CCDirector sharedDirector] openGLView] addSubview:picker.view];
    [[CCDirector sharedDirector] stopAnimation];
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
    [[CCDirector sharedDirector] resume];
    CCScene *Scene = [CCScene node];
    CCLayer *Layer = [GameWinScreen node];
    [Scene addChild:Layer];

    [picker.view removeFromSuperview];
    [[CCDirector sharedDirector] startAnimation];
    [picker dismissModalViewControllerAnimated:YES];
    [[CCDirector sharedDirector] replaceScene:Scene];


alt text

But, the problem is my game is in landscape mode. So, I need the mail sheet to display in landscape mode. But, here the mail sheet is displayed in portrait mode. And the keyboard is appearing in landscape mode. But, the mail composure sheet is in portrait mode.

And how can we change the "sent from my iPhone" to "Sent From My iPad"

Thank you.

alt text


You can try to manually rotate view...:

CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90));

[picker.view setTransform:landscapeTransform];

You can make your own mailcomposer that is derived from MFMailComposeViewController and you can overwrite only the function shouldAutorotateToInterfaceorientation. I didn't try this, just give you an idea.

Who is managing your EmailScene object? If you have followed the MVC pattern, try present the MFMailComposeViewController object using the viewController of EmailScene view. This will work provided you have supported all orientations in the view controller.


-(void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated

Instead of adding the MFMailComposeViewController's view as a subview.

Edit: Try to present the MFMailComposeViewController using the root view controller.

Need Your Help

Slow php script

php mysql function select

I really dislike Full-Text just because I havent got it to work for me so I decided to use a long match against. I was wondering if there's a way to improve this code in speed. I understand its bul...