错误:地址不包含指向目标文件中的节的部分



嗨,我在论坛上搜索了这里,但没有找到帮助,所以我正在发布新的。这是场景,我正在主根视图控制器中创建一个mfmailcomposeviewcontroller,我通过调用presentviewcontroller来显示它,但是当它被关闭时,我收到此错误:

error: address doesn't contain a section that points to a section in a object file

我使用的代码如下:

-(void) mailButtonTapped
{
if ([MFMailComposeViewController canSendMail]) {
    mailViewController_ = [[MFMailComposeViewController alloc] init];
    mailViewController_.mailComposeDelegate = self;
    [mailViewController_ setSubject:@"Try ..."];
    [mailViewController_ setMessageBody:@"Hey I just tried ..." isHTML:NO];
    NSData *videoData = [NSData dataWithContentsOfURL:movieURL_];
    [mailViewController_ addAttachmentData:videoData mimeType:@"video/quicktime" fileName:@"Video.mov"];
    [self presentViewController:mailViewController_ animated:YES completion:nil];
}
else {
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sharing Not Possible" message:@"Configure your mail to send the mail" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
    [alertView show];
    [alertView release];
    }
}
-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
NSString *title = @"Email";
NSString *msg = nil;
if (result == MFMailComposeResultFailed)
    msg = @"Unable to send, check your email settings";
else if (result == MFMailComposeResultSent)
    msg = @"Email Sent Successfully!";
else if (result == MFMailComposeResultCancelled || result == MFMailComposeResultSaved)
    msg = @"Sending Cancelled";
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
[self dismissViewControllerAnimated:YES completion:nil];

}

关闭后,我收到错误:

error: address doesn't contain a section that points to a section in a object file

请帮助我

我也遇到了这个错误,但有另一种情况。我有一个用@property(赋值,非原子)定义的块属性。

为了解决这个问题,我用@property(复制,非原子)声明了我的块属性。

干杯

当访问不再存在的对象/指针时,会发生此错误。并且还可能导致其他不良访问,0x00000访问值等。错误。

所以你正在删除/释放一个指针,然后稍后访问.

通过查看代码,这只是没有调试的猜测,您将第二个 AlertView 的委托设置为 self,但随后立即关闭视图控制器。

尝试在关闭警报视图或按下按钮后关闭,或者只是将 AlertView 委托设置为 nil。

即使这不是完全错误,主要原因是您正在释放一个对象,然后尝试调用函数或访问它。

你可以像这样使用它:

MFMailComposeViewController *mailViewController_ = [[MFMailComposeViewController alloc] init];
    mailViewController_.mailComposeDelegate = self;
    [mailViewController_ setSubject:@"Try ..."];
    [mailViewController_ setMessageBody:@"Hey I just tried ..." isHTML:NO];
    NSData *videoData = [NSData dataWithContentsOfURL:movieURL_];
    [mailViewController_ addAttachmentData:videoData mimeType:@"video/quicktime" fileName:@"Video.mov"];
    [self presentViewController:mailViewController_ animated:YES completion:nil];
[mailViewController_ release];

我也遇到了这个问题,但由于一个非常愚蠢的错误,我在继承自UIView的类上编写了一个名为 frame 的属性(这是一个UITableViewCell但我认为每个继承自 UIView 的类都会发生这种情况)这覆盖了原始 frame 属性并导致此错误。

只需更改属性名称即可修复。

完成需要在完成解除动画时调用一个块。

只需删除"完成:nil",它应该可以工作!

问候。

最新更新