cannot dismiss the email composer view in iphone?

Posted by Warrior on Stack Overflow See other posts from Stack Overflow or by Warrior
Published on 2010-03-27T17:51:25Z Indexed on 2010/03/27 17:53 UTC
Read the original article Hit count: 400

Filed under:
|
|

I am new to iphone development.I have created a tabbar based application . In the first i want the email composer to be displayed. I am able to display it but the cancel and send button are not working,I don't know where do i go wrong .Please help me out. Here is my code.

 - (void)viewDidLoad {
[super viewDidLoad];
[self displayComposerSheet];    
}

-(void)displayComposerSheet 
{   

picker = [[MFMailComposeViewController alloc] init];

[[picker navigationBar] setTintColor:[UIColor blackColor]];

picker.mailComposeDelegate = self;

if ([MFMailComposeViewController canSendMail]) {

    [picker setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]];

    [picker setSubject:@"Sample"];

}
[self.view addSubview:picker.view];
[self presentModalViewController:picker animated:YES];

}

 - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{   
switch (result)
{
    case MFMailComposeResultCancelled:

        alert = [[UIAlertView alloc] initWithTitle:@"Message Cancelled!" message:@"Your email has cancelled to send" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];

        [alert release];

        break;

    case MFMailComposeResultSaved:

        alert = [[UIAlertView alloc] initWithTitle:@"Message Saved!" message:@"Your email has saved to send" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];

        [alert release];

        break;

    case MFMailComposeResultSent:

        alert = [[UIAlertView alloc] initWithTitle:@"Message Sent!" message:@"Your email has to sent" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alert release];;

        break;

    case MFMailComposeResultFailed:

        alert = [[UIAlertView alloc] initWithTitle:@"Message Failed!" message:@"Your email has cancelled to send" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];

        [alert show];

        [alert release];    

        break;

    default:

        alert = [[UIAlertView alloc] initWithTitle:@"Message Failed!" message:@"Your email has not to send" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];

        [alert release];

        break;
}

[self dismissModalViewControllerAnimated:YES];

 }

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uitabbar