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