2013-04-29 1 views
2

최근에 iOS 앱에서 이메일을 구현하는 방법을 배웠습니다. 이것이 의미하는 바를 혼란스럽게 생각합니다. 나는 오류와 코드를 첨부했다. 내가하려는 일은 사용자가 UITextField에 정보를 입력하게하고 보내기 버튼을 누르면 내 이메일로 전송됩니다. 지난 몇 달 동안 나는이 실수를 저질렀다. 나는 아직도 혼란 스럽다. 미리 감사드립니다.MFMailComposeViewController confusion

Information:Information:Building target 'RPSS' from 'RPSS' with configuration 'Debug' for architecture 'i386' using 'Simulator - iOS 4.3' sdk 
    Error:Error:The following build commands failed: 
    Error:Error:RPSS: 
    Error:Error:Ld "/Users/abowmanj/Documents/Xcode projects/RPSS/build/Debug-    iphonesimulator/RPSS.app/RPSS" normal i386 
    Error:Error:Build Finished with Error: 1 
    Undefined symbol '_OBJC_CLASS_$_MFMailComposeViewController' referenced from: 
    Error:Error:objc-class-ref-to-MFMailComposeViewController in RPSSViewController.o 
    Error:Error:objc-class-ref-to-MFMailComposeViewController in SupportPage.o 
    build/Debug-iphonesimulator/RPSS.app/RPSS 
    Information:Information:ld: symbol(s) not found 
    Information:Information:collect2: ld returned 1 exit status 

코드 :

-(void) showEmailModalView { 
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
    picker.mailComposeDelegate = self;// <- very important step if you want feedbacks on what the user did with your email sheet 

    [picker setSubject:@"Comments, Suggestions, Etc."]; 

    // Fill out the email body text 
    NSString *emailBody = [NSString stringWithFormat: @"%@", supportInput.text]; 

    [picker setMessageBody:emailBody isHTML:YES]; // depends. Mostly YES, unless you want to send it as plain text (boring) 

    picker.navigationBar.barStyle = UIBarStyleDefault; // choose your style, unfortunately, Translucent colors behave quirky. 

    [self presentModalViewController:picker animated:YES]; 
    [picker release]; 
} 

- (void)mailComposeController:(MFMailComposeViewController*)controller  didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { 
    if (result == MFMailComposeResultSent) { 
     UIAlertView *sentMail = [[UIAlertView alloc] initWithTitle: @"Mail Sent:" message: @"Your mail has been sent!" delegate: self cancelButtonTitle: nil otherButtonTitles: @"Close", nil]; 
     [sentMail show]; 
     [sentMail release]; 
    } 

    [self dismissModalViewControllerAnimated:YES]; 
} 

-(IBAction) send : (id) sender { 
    // We must always check whether the current device is configured for sending emails 
    if ([MFMailComposeViewController canSendMail]) { 
     [self showEmailModalView]; 
    } 
    else { 
     UIAlertView *a = [[UIAlertView alloc] initWithTitle: @"Error" message: @"Device not configured to send mail." delegate: self cancelButtonTitle: nil otherButtonTitles: @"Ok", nil]; 
     [a show]; 
     [a release]; 
    } 
} 

답변