2010-10-06 2 views
2

J'utilise le contrôleur MFMailComposeViewController comme ceci:MailComposeViewController - quand j'appuyez sur le bouton « Annuler » je ne vois pas le panneau avec « Projet », boutons « Enregistrer le brouillon » et « Annuler »

MFMailComposeViewController *picker1 = [[MFMailComposeViewController alloc] init]; 
picker1.mailComposeDelegate = self; 
[picker1 setSubject:@"I have a pencil for you"]; 
UIImage *roboPic = [UIImage imageNamed:@"RobotWithPencil.jpg"]; 
NSData *imageData = UIImageJPEGRepresentation(roboPic, 1); 
[picker addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"RobotWithPencil.jpg"]; 
NSString *emailBody = @"This is a cool image of a robot I found. Check it out!"; 
[picker1 setMessageBody:emailBody isHTML:YES]; 
picker1.navigationBar.barStyle = UIBarStyleBlack; 
[self presentModalViewController:picker1 animated:YES]; 
[picker1 release]; 

Lorsque J'appuie sur le bouton "Annuler" Je ne vois pas le panneau avec les boutons "Brouillon", "Enregistrer brouillon" et "Annuler", l'écran est verrouillé/gelé mais le panneau avec les boutons mentionnés ci-dessus n'apparaît pas.

Je serai heureux de recevoir de l'aide.

Merci à l'avance Moshe

Répondre

1
you have to use this for mail composing. and in interface file write this delegte MFMailComposeViewControllerDelegate . also import messageUi framework. its working. 


#pragma mark Compose Mail 
// Displays an email composition interface inside the application. Populates all the Mail fields. 
-(void)displayComposer 
{ 
    if(![MFMailComposeViewController canSendMail]) 
    { 
     [self setUpMailAccount]; 
     return; 
    } 

    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
    picker.mailComposeDelegate = self; 
    [picker setSubject:@"Strpy's Revange"]; 
    [[picker navigationBar] setTintColor:[UIColor blackColor]]; 


    // Set up recipients 
    NSArray *toRecipients = [NSArray arrayWithObject:@""]; 
    NSArray *ccRecipients = [NSArray arrayWithObjects:@"", @"", nil]; 
    NSArray *bccRecipients = [NSArray arrayWithObject:@""]; 

    [picker setToRecipients:toRecipients]; 
    [picker setCcRecipients:ccRecipients]; 
    [picker setBccRecipients:bccRecipients]; 

    // Fill out the email body text 

    if([UIAppDelegate gameCodeFlag]==0) 
    { 
     NSString *emailBody = [NSString stringWithFormat:@"Game Score! %d",[UIAppDelegate scorePost]]; 
     [picker setMessageBody:emailBody isHTML:NO]; 
    } 
    else { 
     [UIAppDelegate readFriendPlist]; 
     NSString *emailBody = [NSString stringWithFormat:@"Game Code! %@",[UIAppDelegate gameCode]]; 
     [picker setMessageBody:emailBody isHTML:NO]; 
    } 

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



// Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation. 
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
    // Notifies users about errors associated with the interface 
    switch (result) 
    { 
     case MFMailComposeResultCancelled: 
      break; 
     case MFMailComposeResultSaved: 
      break; 
     case MFMailComposeResultSent: 
     { 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Sending..." 
                  delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
      [alert show]; 
      [alert release]; 
      break; 
     } 
     case MFMailComposeResultFailed: 
      break;   
     default: 
     { 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email" message:@"Sending Failed - Unknown Error :-(" 
                  delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
      [alert show]; 
      [alert release]; 
     } 
     break; 
    } 
    [self dismissModalViewControllerAnimated:YES]; 
    if([UIAppDelegate gameCodeFlag]==1) 
    { 
     [[CCDirector sharedDirector] pushScene:[StorePage scene]]; 

    } 


} 
Questions connexes