开发者

MailComposeViewController - when i press button "Cancel" i don't see the panel with "Draft" ,"Save Draft" and "Cancel" buttons

I am using the MFMailComposeViewController Controller like this:

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

When I press the "Cancel" button I don't see the panel with "Draft", "Save Draft" and "Cancel" buttons, the screen is locked/frozen but the panel with buttons mentioned above doesn't appear.

I will be glad to get any assis开发者_StackOverflowtance.

Thanks in advance Moshe


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

    }


}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜