How to dismiss the MFMailComposeViewController in cocos2d ?

Posted by srikanth rongali on Stack Overflow See other posts from Stack Overflow or by srikanth rongali
Published on 2010-05-08T05:31:35Z Indexed on 2010/05/12 5:44 UTC
Read the original article Hit count: 340

I have changed my code to this way. Now mail controller is opening in landscape mode. But the problem is If I touch on cancel button or send button the mail controller is not dismissing its view. How can I do it ?

-(void)goToFirstScreen:(id)sender
{
    NSLog(@"goToFirstScreen: ");
    CCScene *Scene = [CCScene node];
    CCLayer *Layer = [EmailScene node];
    [Scene addChild:Layer];

    [[CCDirector sharedDirector] setAnimationInterval:1.0/60];
    [[CCDirector sharedDirector] pushScene: Scene];
}  

Th EmailScene class is

#import "EmailScene.h"
#import "testOfEnd.h"

@implementation EmailScene

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


-(void)displayComposerSheet
{
    [[CCDirector sharedDirector] pause];

     picker = [[MFMailComposeViewController alloc] init];
     picker.mailComposeDelegate = self;

    [[[CCDirector sharedDirector] openGLView] addSubview:picker.view];
    [[CCDirector sharedDirector] stopAnimation];
    [picker presentModalViewController:picker animated:YES];
    [picker release];
 }   


- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{

    [[CCDirector sharedDirector] resume];
    //dismiss view after otherwise the code is not executed
    [picker.view removeFromSuperview];
    [[CCDirector sharedDirector] startAnimation];
    [picker dismissModalViewControllerAnimated:YES];

    //return to previous scene
    CCScene *Scene = [CCScene node];
    CCLayer *Layer = [testOfEnd node];
    [Scene addChild:Layer];
    [[CCDirector sharedDirector] replaceScene:Scene];
}  


@end  

Thank You.

© Stack Overflow or respective owner

Related posts about cocos2d-iphone

Related posts about cocoa-touch