我有一个使用表格视图控制器来显示一些项目的应用程序,在单击其中一个项目后,您可以选择通过电子邮件发送该项目。一旦发生这种情况,我使用苹果“MailComposer”提供的代码,并发送邮件。然而,在此之后,表格视图中的滚动不像以前那么平滑。
我检查了“泄漏”,我的代码中没有泄漏,但是当 MFMailComposeViewController 的模态视图控制器和当我关闭我的控制器时,所有对象分配仍然存在。我怎样才能摆脱所有的对象分配?任何帮助将不胜感激。谢谢你。
-奥斯卡
更新:
我已经意识到只有在您单击 MFMailComposeViewController 上的 To: 文本字段并输入内容后才会发生延迟,一旦输入内容就会出现内存泄漏并且应用程序会运行缓慢。同样的事情也发生在 Apple 的 Mail Composer 中。我正在使用模拟器也许这就是为什么?其他人有类似的经历吗?
我按下控制器的方式是:
-(void)displayComposerSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSString *mailSubject = appDelegate.mailTitle;
NSString *mailBody = appDelegate.mailLink;
NSString *formattedString = [NSString stringWithFormat:@"<a href='%@'>%@</a>", mailBody, mailBody];
[picker setSubject:mailSubject];
// Set up recipients
//NSArray *toRecipients = [NSArray arrayWithObject:@"somemail@hotmail.com"];
//NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil];
//NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"];
//[picker setToRecipients:toRecipients];
//[picker setCcRecipients:ccRecipients];
//[picker setBccRecipients:bccRecipients];
// Attach an image to the email (Warning this causes a memory leak aknowledged by Apple)
//NSString *path = [[NSBundle mainBundle] pathForResource:@"news_icon" ofType:@"png"];
//NSData *myData = [NSData dataWithContentsOfFile:path];
//[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"rainy"];
// Fill out the email body text
[picker setMessageBody:formattedString isHTML:YES];
[self presentModalViewController:picker animated:YES];
[picker release];
}
并在这里忽略它:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
....
[self dismissModalViewControllerAnimated:YES];
}