gpt4 book ai didi

objective-c - 关闭 MFMailComposeViewController : error: address doesn't contain a section that points to a section in a object file 时出现奇怪错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:20:57 26 4
gpt4 key购买 nike

我收到一个非常奇怪的错误 MFMailCompseViewController。错误是“错误:地址不包含指向目标文件中某个部分的部分”。在 MFMailCompseViewController 关闭并且电子邮件实际发送后应用程序崩溃。

这是特定于 MFMailComposeViewController 的,因为我试图以模态方式呈现一个普通 View Controller ,但它很好地消除了。

这是我为调用和显示邮件编辑器编写的代码:

- (void) emailImage:(UIImage *)img {
//verified that the image is being returned correctly
UIImage *img1 = [[_delegate photoBrowser:self photoAtIndex:0] underlyingImage];

MFMailComposeViewController *mfViewController = [[MFMailComposeViewController alloc] init];
mfViewController.mailComposeDelegate = self;

NSString *subject = @"Check out this photo I took - Cap That App";

[mfViewController setSubject:subject];
NSData *imgData = UIImageJPEGRepresentation(img1, 1.0);
[mfViewController addAttachmentData:imgData mimeType:@"image/jpg" fileName:@"photo.jpg"];

NSString *contactMessage = @"\n\n<a href=\"http://www.agilerocket.com\">Sent via Cap That - Available in the Apple App Store</a>";

[mfViewController setMessageBody:contactMessage isHTML:YES];

[self presentViewController:mfViewController animated:YES completion:nil];

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Status:" message:@"" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil] autorelease];

switch (result) {
case MFMailComposeResultCancelled:
alert.message = @"You chose not to send the email.";
break;
case MFMailComposeResultSaved:
alert.message = @"Your email was saved as a draft. It has not been sent yet.";
break;
case MFMailComposeResultSent:
alert.message = @"Your email has been sent!";
break;
case MFMailComposeResultFailed:
alert.message = @"There was an error sending the email. Please verify your email is working and try again.";
break;
default:
alert.message = @"You chose not to send the email.";
break;
}

[self dismissViewControllerAnimated:YES completion:^(void) {
[alert show];
}];

提前感谢任何人对此的帮助。

最佳答案

我在我的应用程序中遇到了同样的错误,在 HUD 上按点击手势操作。我的手势识别器方法是使用 HUD 上的 block 属性来执行需要的操作,这就是它崩溃的地方( block 中的代码永远无法运行)。显然该程序无法访问该代码,并且由于您还有一个完成 block ,它可能是正在发生的事情的线索。

我没有发现我在我的代码中做错了什么,而且您似乎也没有做错,所以这可能是一个错误。您是否有机会运行 Xcode(4.4 或 4.5)的开发人员预览版?

编辑:原来我的问题是代码块属性在它有机会运行之前被释放了。我认为类似的事情可能会发生在你的情况下, alert var。您可以尝试在完成 block 内移动警报初始化吗?

编辑 2: 作为替代方案,尝试为警报初始化添加前缀 __weak(如果您的目标是 iOS 4.3,则为 __unsafe_unretained),应该这样做。如果您不使用 ARC,请改用 __block

关于objective-c - 关闭 MFMailComposeViewController : error: address doesn't contain a section that points to a section in a object file 时出现奇怪错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11535251/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com