0

私は Unity プロジェクトとして非常に単純なプロジェクトを持っており、新しい機能を追加したい - アプリケーションのスクリーンショットを電子メールで送信する,

私はそれを行うために多くの方法を試していますが、私はIOSのニービーであり、あなたの助けが必要です:(

このバージョンはエラーなく動作していますが、ボタンをクリックしてもメールフォームが表示されません

コードは非常に短くシンプルです-誰かが私を助けてくれることを願っています:(((

SampleViewsAppDelegate.h

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <MapKit/MKMapView.h>
#import <MessageUI/MessageUI.h>

#import "tiDFusionMobile.h"

@interface SampleViewsAppDelegate : NSObject     <UIApplicationDelegate,MFMailComposeViewControllerDelegate> {

    ///Application Window
    UIWindow *mWindow;

    UIViewController *rootViewController;

    ///Application views
    UIView    *mRender;

    tiComponent* mPlayer;
}

///IBOutlet properties
@property (nonatomic, retain) IBOutlet UIWindow *mWindow;
@property (nonatomic, retain) IBOutlet UIViewController *rootViewController;
@property (nonatomic, retain) IBOutlet UIView *mRender;


- (IBAction)openMailBtn:(id)sender;
- (void)start;
- (void)stop;

@end

ファイルミリメートル

#import "SampleViewsAppDelegate.h"
@implementation SampleViewsAppDelegate
@synthesize mWindow;
@synthesize mRender;
@synthesize rootViewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
{
    // allocate the Component
    mPlayer = [tiComponent alloc];

    // set correct renderer
    [mPlayer setRendererType:[tiComponent TI_RENDERER_GLES2]];

    // initialze
    [mPlayer initialize:mRender];

    // start scenario
    [self start];
    return YES;
}

- (void)dealloc
{
    [self stop];

    //If the player is still instanciated, it is terminated and released
    if (mPlayer)
    {
        [mPlayer terminate];    
        [mPlayer release];
        mPlayer = nil;
    }

    [mRender release];

    [mWindow release];

    [super dealloc];
}

- (IBAction)openMailBtn:(id)sender {

    rootViewController = (UIViewController*)
    [(SampleViewsAppDelegate*)[[UIApplication sharedApplication] delegate] rootViewController];

    if ([MFMailComposeViewController canSendMail]) {
    // compose
    MFMailComposeViewController* mail = [[MFMailComposeViewController alloc] init];
    mail.mailComposeDelegate = self;

    //format message
    NSArray *recipientsArray = [[NSArray alloc] initWithObjects:@"test@aaaa.com", nil];
    [mail setToRecipients:recipientsArray];
    NSString *emailBody = @"DSDSDSDS";
    [mail setSubject:[NSString stringWithFormat:@"AAAAAA"]];

    //UIImage *myImage = [UIImage imageNamed:@"mobiletuts-logo.png"];
    //NSData *imageData = UIImagePNGRepresentation(myImage);
    //[mail addAttachmentData:imageData mimeType:@"image/png" fileName:@"mobiletutsImage"];

    [mail setMessageBody:emailBody isHTML:YES];

    //send
    //if (controller)
        [rootViewController presentModalViewController:mail animated:YES];
    [mail release];

    } else {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
                                                        message:@"Your device doesn't support the composer sheet"
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles: nil];
        [alert show];
        [alert release];
    }
 }

#pragma mark - MFMailComposeController delegate

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Mail saved: you saved the email message in the Drafts folder");
            break;
        case MFMailComposeResultSent:
            NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send the next time the user connects to email");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Mail failed: the email message was nog saved or queued, possibly due to an error");
            break;
        default:
            NSLog(@"Mail not sent");
            break;
    }

    [self dismissViewControllerAnimated:YES complete:nil];
}

- (void)start
{
    if (mPlayer != nil) {
        BOOL isLoaded = [mPlayer loadScenario:@"Scenario/SampleViews_GLES1/project.dpd"];
            if (isLoaded) {
            [mPlayer playScenario];
        }       
    }
}

- (void)stop
{
    if (mPlayer && ![mPlayer isScenarioPaused]) {
        [mPlayer pauseScenario];
    }

}

@end
4

1 に答える 1