我有一个应用程序,它使用表视图控制器来显示一些项目,单击其中一个项目后,您可以选择通过电子邮件发送此项目。一旦发生这种情况,我就使用苹果“邮件编辑器”提供的代码,并发送邮件。然而,在这之后,表视图中的滚动就不像以前那样平滑了。
我检查了“leaks”,代码中没有泄漏,但是当mfmailcomposeviewcontroller的模式视图控制器,以及当我解除控制器时,所有的对象分配仍然存在时,会有大量的对象分配。我怎样才能摆脱所有的对象分配呢?任何帮助都将不胜感激。谢谢您。
-奥斯卡
更新:
我已经意识到,只有当您单击mfmailcomposeviewController上的to:textfield并键入某些内容时,才会发生延迟,一旦键入了某些内容,就会出现内存泄漏,应用程序也会迟缓。同样的事情也发生在苹果的邮件作曲家身上。我用的是模拟器也许这就是为什么?.其他人有席米拉的经验吗?
我给控制器施压的方式是:
-(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];
}