How to dismiss the MFMailComposeViewController in cocos2d ?
- by srikanth rongali
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.