如何使用 MFMailComposeViewController
我在我的应用程序中使用 MFMailComposeViewController ,邮件发送部分似乎没问题。 但是当我离开邮件应用程序时,事情就出了问题:
- one toolbar (UIToolbar object) has disappeared.
- one pointer (UIImageView*) has become nil, without me doing anything for that to happen.
换句话说,尽管我不希望它改变,但呼叫环境发生了变化。 我的错误可能在哪里?
这是我的代码,以防有人看到错误:
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
[controller dismissModalViewControllerAnimated:YES];
}
-(IBAction)sendAsEMail {
MFMailComposeViewController *mailComposeViewController=[[MFMailComposeViewController alloc] init];
mailComposeViewController.mailComposeDelegate=self;
[mailComposeViewController setSubject:@"Mail subject"];
[mailComposeViewController setMessageBody:@"This is for you !" isHTML:NO];
[mailComposeViewController addAttachmentData:
[NSData dataWithContentsOfFile:[[My_ViewController getDocDir] stringByAppendingPathComponent:
[pictureNames objectAtIndex:userItemSelected]]]
mimeType:@"image/png" fileName:@"Picture.png"];
if (mailComposeViewController) [self presentModalViewController:mailComposeViewController animated:YES];
[mailComposeViewController release];
}
感谢您提供任何相关信息。
I am using MFMailComposeViewController in my app and the mail sending part seems to be OK.
But when I leave the mail app, things go wrong :
- one toolbar (UIToolbar object) has disappeared.
- one pointer (UIImageView*) has become nil, without me doing anything for that to happen.
In other words the calling environment is changed although I do not want it to change.
Where could be my mistake?
Here is my code, in case someone can see something wrong :
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
[controller dismissModalViewControllerAnimated:YES];
}
-(IBAction)sendAsEMail {
MFMailComposeViewController *mailComposeViewController=[[MFMailComposeViewController alloc] init];
mailComposeViewController.mailComposeDelegate=self;
[mailComposeViewController setSubject:@"Mail subject"];
[mailComposeViewController setMessageBody:@"This is for you !" isHTML:NO];
[mailComposeViewController addAttachmentData:
[NSData dataWithContentsOfFile:[[My_ViewController getDocDir] stringByAppendingPathComponent:
[pictureNames objectAtIndex:userItemSelected]]]
mimeType:@"image/png" fileName:@"Picture.png"];
if (mailComposeViewController) [self presentModalViewController:mailComposeViewController animated:YES];
[mailComposeViewController release];
}
Thanks for any piece of relevant information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个链接,它详细解释了
检查
Try out this link it explain in detail
Check at this link.