How we should load theMFMailComposeViewController in cocos2d ?

Discussion in 'iOS Programming' started by srikanthrongali, May 10, 2010.

  1. srikanthrongali macrumors newbie

    Joined:
    Apr 30, 2010
    #1
    I am writing an app in using cocos2d. This method I have written for the selector goToFirstScreen: . The view is in landscape mode. I need to send an email. So, I need to launch the MFMailComposeViewController. I need it in portrait mode.

    But, the control is not entering in to viewDidLoad of the mailMe class. The problem is in goToScreen: method. But, I do not get where I am wrong ?
    Code:
    -(void)goToFirstScreen:(id)sender
    {
    
        CCScene *Scene = [CCScene node];
        CCLayer *Layer = [mailME node];
    
        [Scene addChild:Layer];
    
        [[CCDirector sharedDirector] setAnimationInterval:1.0/60];
        [[CCDirector sharedDirector] pushScene: Scene];
    }    
    mailMe is the class in which I wrote the code for mail using MFMailComposeViewController.

    Hi, I need to open a webpage when I touched a label in the coco2d layer. It should be opened by using safari. I am stuck at adding the view to the coco2d layer ? How can I resolve this ?

    Thank you .
     
  2. srikanthrongali thread starter macrumors newbie

    Joined:
    Apr 30, 2010
    #2
    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 ?
    Code:
    -(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   
    
    
    When I touch cancel button, in the log no message is displayed and the mail controller not dismissed.
    But when I touch the send button, in the log

    Error loading /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator: dlopen(/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator, 265): Library not loaded: /System/Library/PrivateFrameworks/MobileWirelessSync.framework/MobileWirelessSync Referenced from: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator Reason: image not found 2010-05-12 12:08:18.640 enemyTest2[1233:5717] [+[AccountsManager _migrateAccountsIfNeeded]] Accounts migration failed

    What about this message , how can I dismiss model view controller.

    Thank You.
     

Share This Page