我正在打开电子邮件表以发送文件。它工作得很好,只是我不能回到我的应用程序。
当我点击取消按钮时,它会询问是否删除或保存草稿,并留在那里。它不会返回应用程序页面。
代码:
//send email log-------------------------
NSLog(@"mail");
[[CCDirector sharedDirector] pause];
picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
//Fill in the email as you see fit
NSArray *toRecipients = [NSArray arrayWithObject:@"name@gmail.com"];
[picker setToRecipients:toRecipients];
NSArray *paths2 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dataPath = [[paths2 objectAtIndex:0] stringByAppendingPathComponent:@"Test.txt"];
NSData *data = [NSData dataWithContentsOfFile:dataPath];
[picker addAttachmentData:data mimeType:@"text/txt" fileName:@"Test.txt"];
NSString *emailBody = @"Test ";
[picker setMessageBody:emailBody isHTML:NO];
[picker setSubject:@"hardware test ## "];
//display the view
[[[CCDirector sharedDirector] openGLView] addSubview:picker.view];
[[CCDirector sharedDirector] stopAnimation];
编辑:
我在这里添加了答案中建议的函数,当我点击取消时,他调用了该函数,但它保留在该表中。我不得不说我使用的是 cclayer (cocos2d),所以该层定义为:
@interface HelloWorldLayer : CCLayer< MFMailComposeViewControllerDelegate>
还有什么建议吗?
非常感谢。