开发者

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

-(void)displayComposerSheet;

@end

@implementation EmailScene

- (id) init {

    self = [super init];
    if (self != nil) {
        [self displa开发者_如何学CyComposerSheet];
    }
    return self;
}
-(void)displayComposerSheet
{

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

    NSArray *toRecipients = [NSArray arrayWithObject:@"srikanth.rongali786@gmail.com"]; 
[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];
}

@end  

alt text http://www.freeimagehosting.net/uploads/4a77b9ceb9.png

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 http://www.freeimagehosting.net/uploads/3eb39ea1de.png


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.

Use:

-(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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜