m4f*_*050 1 iphone exc-bad-access ios mfmailcomposeviewcontroller
好的,这一直困扰着我一段时间......
我已检查过,所有其他问题/答案都与非ARC项目有关.
每当我提出MFMCvc并且我快速取消消息时,我就会在iPhone上收到Thread1:EXEC_BAD_ACCESS错误消息.可以在iPad上正常工作,或者我让它静坐(比如30秒或更长时间)
有什么建议吗?(除了放一个计时器而不是在计时器启动之前解雇?)
BTW我对MFMessageComposeViewController做了同样的事情,它在iPhone和iPad上运行良好.
这是我的代码来呈现它
if (([action isEqualToString:@"EMail"]) && contact.length>0)
{
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
if([MFMailComposeViewController canSendMail]) {
[mailViewController setSubject:@""];
[mailViewController setMessageBody:@"" isHTML:NO];
[mailViewController setToRecipients:[NSArray arrayWithObject:contact]];
[mailViewController setMailComposeDelegate:self];
[self presentModalViewController:mailViewController animated:NO];
}
}
Run Code Online (Sandbox Code Playgroud)
这是我解雇它的地方
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result)
{
case MFMailComposeResultCancelled:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Send EMail" message:@"EMail Has Been Cancelled"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
break;
case MFMailComposeResultFailed:
{
NSLog(@"Error");
}
break;
case MFMailComposeResultSent:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Send EMail" message:@"EMail Has Been Sent"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
break;
case MFMailComposeResultSaved:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Send EMail" message:@"EMail Has Been Saved"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
break;
default:
break;
}
[self dismissModalViewControllerAnimated:NO];
}
Run Code Online (Sandbox Code Playgroud)
1)不行:[self dismissModalViewControllerAnimated:NO];
- 需要:[controller dismissModalViewControllerAnimated:NO];
?您想要关闭MFMailComposeViewController.
2)MFMailComposeViewController可能还有问题没有被保留.当我使用这个类时,我已经为控制器创建了一个属性.这可能值得一试.
// in the interface definition
@property (nonatomic, strong) MFMailComposeViewController* mailComposer;
Run Code Online (Sandbox Code Playgroud)
然后
// at creation time
if (([action isEqualToString:@"EMail"]) && contact.length>0)
if(![MFMailComposeViewController canSendMail]) return; // bail early if can't send mail
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
[mailViewController setSubject:@""];
[mailViewController setMessageBody:@"" isHTML:NO];
[mailViewController setToRecipients:[NSArray arrayWithObject:contact]];
[mailViewController setMailComposeDelegate:self];
[self presentModalViewController:mailViewController animated:NO];
[self setMailComposer: mailViewController];
// if not using ARC then: [mailViewController release];
Run Code Online (Sandbox Code Playgroud)
然后在didFinish中
[[self mailComposer] dismissModalViewControllerAnimated:YES];
[self setMailComposer: nil];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1306 次 |
最近记录: |