2012-12-02 33 views
6

您好我在這裏搜索了論壇,但沒有找到幫助,所以我發佈它新。下面是這種情況,我創建主RootViewController的一個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]; 

}

駁回i之後收到錯誤:

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

請幫我

+0

您使用ARC嗎? – Max

+0

不,我沒有使用 – kashif789us

+0

我試圖釋放mailViewController後dismissingviewcontroller,但沒有運氣 – kashif789us

回答

-1

完成期望當解除動畫完成時調用一個塊。

只要刪除「完成:無」,它應該工作!

問候。

+0

完成:nil非常好......它不應該在任何情況下產生問題。 – Nishant

15

我也有這個錯誤,但與另一種情況。我有一個用@property(assign,nonatomic)定義的塊屬性。

要解決此問題,我使用@property(copy,nonatomic)聲明瞭我的block屬性。

乾杯

+0

感謝您的問題,很明顯,但不可能單獨找到它-_-' –

+0

我得到了同樣的問題,我現在修復它.....謝謝 –

0

您可以使用它像這樣:

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]; 
0

我也有這個問題,但一個非常愚蠢的錯誤造成的,我在從UIView繼承的類寫了一個名爲frame財產(這是一個UITableViewCell,但我認爲這將發生在從UIView繼承的每一個類),這覆蓋了原來的frame屬性並導致了這個錯誤。

只是通過更改屬性名稱來修復。

1

當正在訪問的對象/指針不再存在時,會發生此錯誤。並且還會導致其他不良訪問,0x00000訪問等錯誤。

所以你刪除/釋放一個指針,然後再訪問。

從查看代碼,這只是一個沒有調試的猜測,您將第二個AlertView的代理設置爲self,但是立即關閉viewcontroller。

在警報視圖關閉或按下按鈕後嘗試關閉,或者也許只是將AlertView委託設置爲零。

即使這不完全是錯誤,主要原因是某處你正在釋放一個對象,然後試圖調用一個函數或訪問它。

相關問題