How to remove association from a view and a view controller? - iphone

When I try to show the facebook share after having sent an email (using MFMailComposeViewController) I get this error:
A view can only be associated with at most one view controller at a
time! View [EAGLView] is associated with [EmailViewController]. Clear
this association before associating this view with [FacebookView].'
[EmailViewController removeFromParentViewController]; Does nothing
EmailViewController.view = nil; Causes a white screen, even though the email form is long gone.
How to make it forget that I ever sent and email and make the view hierarchy go back to how it was before? The facebook share works if I haven't sent an email.
-(IBAction)ShowEmailForm:(char*)pSubject :(char*)pBody :(char*)pTo
{
Class mailClass = (NSClassFromString(#"MFMailComposeViewController"));
if (mailClass != nil)
{
if ([mailClass canSendMail])
{
self.view = eaglView;
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:[NSString stringWithFormat:#"%s", pSubject]];
// Set up recipients
if( pTo != nil )
{
NSArray *toRecipients = [NSArray arrayWithObject:[NSString stringWithFormat:#"%s", pTo]];
[picker setToRecipients:toRecipients];
}
// Fill out the email body text
[picker setMessageBody:[NSString stringWithFormat:#"%s",pBody] isHTML:YES];
[self presentViewController:picker animated:YES completion:^(){}];
[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
{
[self dismissViewControllerAnimated:YES completion:^(){ printf("Email form done dismissing.\n"); }];
printf("Email form dismissed.\n");
[self removeFromParentViewController];
//Email was sent.
if (result == MFMailComposeResultSent)
{
printf("Email Sent!\n");
NSString *pEmail = [self findEmailAddresses:controller.view : 0];
}
}

Fixed it.
Change
self.view = eaglView;
to
[eaglView addSubview:self.view];

Related

Presenting MFMessageComposeViewController as soon as the user selects a contact from ABPeoplePickerNavigationController

Im working on an app which allows the user to select a contact from phone's address book and displays that contact in the UITableView. Im using following code to pick up the contact;
-(IBAction)pickPhoneContacts:(id)sender //opens phone's address book
{
ABPeoplePickerNavigationController *picker =
[[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentViewController:picker animated:YES completion:nil];
}
//called when user presses the cancel button in the Address book view controller
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController*)peoplePicker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
//called when user pics up a contact from the phone's address book
- (BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person {
[self displayPerson:person]; //calls displayPerson:(ABRecordRef)person to show contact's information in the app
[self dismissViewControllerAnimated:YES completion:NULL];
return NO;
}
//called when the user selects the property of the contact. This method will not be called in the app but included to complete the implementation of the protocol
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)
peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
return NO;
}
//Displays the contact name and the contact's primary number in the app's text fields (add contact view controller)
- (void)displayPerson:(ABRecordRef)person
{
NSString* name = (__bridge_transferNSString*)ABRecordCopyValue(person,kABPersonFirstNameProperty); //Extracts the contact's first name from address book & assigns it to a string value
self.contactNameTextFiled.text = name;
NSString* phone = nil;
//Extracts the first phone number among multiple contact numbers from address book & assigns it to a string value
ABMultiValueRef phoneNumbers = ABRecordCopyValue(person,kABPersonPhoneProperty);
if (ABMultiValueGetCount(phoneNumbers) > 0)
{
phone = (__bridge_transfer NSString*)
ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
}
else
{
phone = #"[None]";
}
self.primaryNumberTextField.text = phone;
CFRelease(phoneNumbers);
}
Now the task is, as soon as the user pics up a contact from the address book, the ABPeoplePickerNavigator should dismiss and immediately MFMessageComposeViewController should present with a default message and the picked contact number. So that the user of the app should send a message to the picked contact number. I have used following code for message compose view controller;
-(void)sendSMS
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = #"Test Message";
controller.recipients = [NSArray arrayWithObjects:#"111222333", nil];
controller.messageComposeDelegate = self;
[self presentViewController:controller animated:YES completion:nil];
}
}
Now please help me where should I call this method so that the MFMessageComposeViewController should present as soon as the ABPeoplePickerNavigationController dismiss.
Use new function dismissViewControllerAnimated: completion: so after completion call send sms as i have edited your code.
- (BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person {
[self displayPerson:person]; //calls displayPerson:(ABRecordRef)person to show contact's information in the app
// [self dismissViewControllerAnimated:YES completion:NULL];
[self dismissViewControllerAnimated:YES completion:^{
[self sendSMS];
}];
return NO;
}
Set animation of your adresscontroller to No when you are dismissing it
[self dismissViewControllerAnimated:NO completion:nil];
Try in
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person;
call
-(void)sendSMS
in dismissViewControllerAnimated:completion: completion handler.
[self dismissViewControllerAnimated:YES completion:{[self sendSMS]}];
Hopes this helps.
in .h file
MFMessageComposeViewController *controller ;
ABPeoplePickerNavigationController *picker;
and in .m just do this
in -(void)sendSMS
{
//other code
[picker presentViewController:controller animated:YES completion:nil];
}

Cancel button on MFMessageComposeViewController does not show up

In my iPhone application, I have just implemented in-app SMS functionality. SMS functionality is working fine. But after opening MFMessageComposeViewController, if user wants to cancel sending sms, they have no option. The only option left is to send an sms, then only return on previous view. There should be a cancel button on navigation bar just as it is in the email composer. Below is the line of code that I wrote to have in-app sms functionality:
-(void) smsComposer{
MFMessageComposeViewController *_smsCompose = [[MFMessageComposeViewController alloc] init];
if ([MFMessageComposeViewController canSendText]) {
_smsCompose.body = #"SMS BODY";
_smsCompose.messageComposeDelegate = self;
[self presentModalViewController:_smsCompose animated:YES];
}
}
Is there anything that I am missing?
Thanks in advance,
PC
Try This....
in .h file
#import <MessageUI/MFMessageComposeViewController.h>
and
#interface TestViewController : UIViewController <MFMessageComposeViewControllerDelegate>
And then Button Click method
-(void)buttonPressed:(UIButton *)button
{
[self sendSMS:#"Body of SMS..." recipientList:[NSArray arrayWithObjects:#"+1-111-222-3333", #"111-333-4444", nil]];
}
MFMessageComposeViewController to create the SMS content and another method for handling the user interaction with the SMS dialog.
-(void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
{
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
if([MFMessageComposeViewController canSendText])
{
controller.body = bodyOfMessage;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
}
And
-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissModalViewControllerAnimated:YES];
if (result == MessageComposeResultCancelled)
NSLog(#"Message cancelled")
else if (result == MessageComposeResultSent)
NSLog(#"Message sent")
else
NSLog(#"Message failed")
}
And remember: You cannot send SMS messages from within the simulator. Test on Device.

'Application tried to present a nil modal view controller on target' error/crash when trying to open mail composer

I have a simple app, which opens a modal view to send email. Am using Xcode 4.2 and iOS 5, and am testing with iOS Simulator. The app crashes with
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'Application tried to present a nil modal view controller on target
.'
when executing the line:
[self presentModalViewController:mailComposer animated:YES];
though I have initialized the object 'mailComposer'.
Class com_FirstViewController.m :
#import "com_FirstViewController.h"
...
#implementation com_FirstViewController
....
....
-(void)showEmailComposer {
Class mailClass = (NSClassFromString(#"MFMailComposeViewController"));
if (mailClass != nil)
{
if ([mailClass canSendMail]) {
NSLog(#"showEmailComposer: Calling displayComposerSheet");
[self displayComposerSheet];
} else {
NSLog(#"showEmailComposer: Calling launchMailAppOnDevice");
[self launchMailAppOnDevice];
}
}
else {
NSLog(#"showEmailComposer: Calling launchMailAppOnDevice");
[self launchMailAppOnDevice];
}
}
#pragma mark -
#pragma mark Compose Mail
-(void) displayComposerSheet {
mailComposer = [[MFMessageComposeViewController alloc] init];
mailComposer.messageComposeDelegate = self;
// Set the mail title
[mailComposer setTitle:#"Mail Title"];
// Set the recipients
NSArray *toRecipients = [NSArray arrayWithObject:#"user#company.com"];
[mailComposer setRecipients:toRecipients];
// EMail Body
NSString *mailBody = #"This is the mail body";
[mailComposer setBody:mailBody];
NSLog(#"present the modal view ctlr");
[self presentModalViewController:mailComposer animated:YES];
}
...
...
Any pointers please?
I have also encountered a similar problem. I allocated an instance of MFMailComposeViewController and tried to present it modally. I also got an exception:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target
This was because the Mail option was disabled in the settings of the iPhone. It can be the case also when no mail account is set up in the device. So the MFMailCompseViewController instance will be nil and presenting it modally will cause the crash.
I used the canSendMail method of the MFMailComposeViewController to get around this issue.
Class mailClass = (NSClassFromString(#"MFMailComposeViewController"));
if (mailClass != nil) {
MFMailComposeViewController * mailView = [[MFMailComposeViewController alloc] init];
mailView.mailComposeDelegate = self;
//Set the subject
[mailView setSubject:emailSubject];
//Set the mail body
[mailView setMessageBody:emailBody isHTML:YES];
//Display Email Composer
if([mailClass canSendMail]) {
[self.navControl presentModalViewController:mailView animated:YES];
}
}
mailComposer = [[MFMessageComposeViewController alloc] init];
is the source of the problem, in my opinion. There's no way the simulator can send SMS messages, so the initializer method may return NULL. Anyways, sou seem to be wanting to send an email, so I'd say you need to use
mailComposer = [[MFMailComposeViewController alloc] init];

UIActionSheet to open up Mail Application iPhone

This issue is something which has me stumped, so hopefully someone can help. I have an UIActionSheet on a view which has three options in. One which takes my user to a new view, one to share via email and one to share via SMS.
I have the UIActionSheet created which works without issue, the new view part of the AlertSheet also works. I have imported the Message.UI framework and set up the mail and SMS pickers and composers which are fine. However, I am having trouble setting the two 'buttons' on the UIActionSheet to open up the mail and SMS.
Normally i would do this through interface builder and connect a UIButton to the actions I have created, but because this is a UIActionSheet it can't be done that way. Sorry for the LONG code but I felt I needed to show everything, so please see below;
-(IBAction)showActionSheet {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#"Choose an Option" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:#"Application Support",#"Share Via Email",#"Share Via SMS",nil];
[actionSheet showInView:self.view];
[actionSheet release];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if(buttonIndex == 0) {
AppSupportView *controller = [[AppSupportView alloc] initWithNibName:#"AppSupportView" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
}
if(buttonIndex == 1) {
}
if(buttonIndex == 2) {
}
}
- (void)dealloc {
[feedbackMsg release];
[super dealloc];
}
- (void)viewDidUnload {
self.feedbackMsg = nil;
}
-(IBAction)showMailPicker:(id)sender {
// The MFMailComposeViewController class is only available in iPhone OS 3.0 or later.
// So, we must verify the existence of the above class and provide a workaround for devices running
// earlier versions of the iPhone OS.
// We display an email composition interface if MFMailComposeViewController exists and the device
// can send emails. Display feedback message, otherwise.
Class mailClass = (NSClassFromString(#"MFMailComposeViewController"));
if (mailClass != nil) {
//[self displayMailComposerSheet];
// We must always check whether the current device is configured for sending emails
if ([mailClass canSendMail]) {
[self displayMailComposerSheet];
}
else {
feedbackMsg.hidden = NO;
feedbackMsg.text = #"Device not configured to send mail.";
}
}
else {
feedbackMsg.hidden = NO;
feedbackMsg.text = #"Device not configured to send mail.";
}
}
-(IBAction)showSMSPicker:(id)sender {
// The MFMessageComposeViewController class is only available in iPhone OS 4.0 or later.
// So, we must verify the existence of the above class and log an error message for devices
// running earlier versions of the iPhone OS. Set feedbackMsg if device doesn't support
// MFMessageComposeViewController API.
Class messageClass = (NSClassFromString(#"MFMessageComposeViewController"));
if (messageClass != nil) {
// Check whether the current device is configured for sending SMS messages
if ([messageClass canSendText]) {
[self displaySMSComposerSheet];
}
else {
feedbackMsg.hidden = NO;
feedbackMsg.text = #"Device not configured to send SMS.";
}
}
else {
feedbackMsg.hidden = NO;
feedbackMsg.text = #"Device not configured to send SMS.";
}
}
// Displays an email composition interface inside the application. Populates all the Mail fields.
-(void)displayMailComposerSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:#"My BMR Index Rating from Total:Health App"];
// Set up recipients
//NSArray *toRecipients = [NSArray arrayWithObject:#""];
//[picker setToRecipients:toRecipients];
NSString *emailSharing = #"I Just discovered that I have a Target Heart Rate of";
// Fill out the email body text
[picker setMessageBody:emailSharing isHTML:YES];
[self presentModalViewController:picker animated:YES];
[picker release];
}
// Displays an SMS composition interface inside the application.
-(void)displaySMSComposerSheet
{
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
NSString *SMSShare = #"I Just discovered that I have a Target Heart Rate of";
// Fill out the email body text
picker.body = SMSShare;
[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 {
feedbackMsg.hidden = NO;
// Notifies users about errors associated with the interface
switch (result)
{
case MFMailComposeResultCancelled:
feedbackMsg.text = #"Result: Mail sending canceled";
break;
case MFMailComposeResultSaved:
feedbackMsg.text = #"Result: Mail saved";
break;
case MFMailComposeResultSent:
feedbackMsg.text = #"Result: Mail sent";
break;
case MFMailComposeResultFailed:
feedbackMsg.text = #"Result: Mail sending failed";
break;
default:
feedbackMsg.text = #"Result: Mail not sent";
break;
}
[self dismissModalViewControllerAnimated:YES];
}
// Dismisses the message composition interface when users tap Cancel or Send. Proceeds to update the
// feedback message field with the result of the operation.
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result {
feedbackMsg.hidden = NO;
// Notifies users about errors associated with the interface
switch (result)
{
case MessageComposeResultCancelled:
feedbackMsg.text = #"Result: SMS sending canceled";
break;
case MessageComposeResultSent:
feedbackMsg.text = #"Result: SMS sent";
break;
case MessageComposeResultFailed:
feedbackMsg.text = #"Result: SMS sending failed";
break;
default:
feedbackMsg.text = #"Result: SMS not sent";
break;
}
[self dismissModalViewControllerAnimated:YES];
}
#end
The issue is obviously that I dont know how to proceed with the (if buttonIndex ==1) etc piece of code to open the mail and SMS
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if(buttonIndex == 0) {
AppSupportView *controller = [[AppSupportView alloc] initWithNibName:#"AppSupportView" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
}
if(buttonIndex == 1) {
}
if(buttonIndex == 2) {
}
}
Any help would be appreciated.
Thanks
looks like all your needed methods are there already..
just add [self showMailPicker:nil] or [self showSMSPicker:nil] to
if(buttonIndex == 1) {
}
if(buttonIndex == 2) {
}
if your second button from the top is your sms button, add showSMSPicker to buttonIndex == 1

Exception in iPhone app : Modal transition is already in progress

I have what I believe is a fairly simple application at the moment based on a few tutorials cobbled together. I'm using XCode 3.2.3 in OSX 10.6.4. It started as a standard iPhone "Window Based Application". Using interface builder I have added a Tab Bar Controller using the O'Reilly video tutorial here:
http://broadcast.oreilly.com/2009/06/tab-bars-and-navigation-bars-t.html
In the first Tab I have a standard UIView with two buttons. Both call the same function to display a UIImagePickerController:
-(IBAction) btnPhotoClicked:(id)sender {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
if((UIButton *)sender == btnChoosePhoto)
{
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
}
I am running the code inside an emulator so only ever click the button called Choose Photo. When the dialogue is released with a photo chosen this function runs:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL *mediaUrl;
mediaUrl = (NSURL *)[info valueForKey:UIImagePickerControllerMediaURL];
if (mediaUrl == nil)
{
imagePuzzle = (UIImage *) [info valueForKey:UIImagePickerControllerEditedImage];
if(imagePuzzle == nil)
{
//--- Original Image was selected ---
imagePuzzle = (UIImage *) [info valueForKey:UIImagePickerControllerOriginalImage];
}
else {
//--- Get the edited image ---
//--- If it was successful the above valueForKey:UIImagePickerControllerEditedImage
//--- would have assigned it already.
}
}
else {
//--- Muppet selected a video
}
// Animate the picker window going away
[picker dismissModalViewControllerAnimated:YES];
ImageViewController *imageViewController = [[ImageViewController alloc] init];
imageViewController.delegate = self;
[self presentModalViewController:imageViewController animated:YES];
[imageViewController release];
}
This is where my problem lies. I've tried many different hacks and iterations but the above code is the simplest to present the problem. When the imageViewController is displayed as a modal dialogue the following exception is thrown:
2010-07-09 15:29:29.667 Golovomka[15183:207] *** Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal
transition from <NewViewController: 0x5915f80> to <ImageViewController: 0x594a350>
while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear
to know the current transition has completed'
How do I cure this? I have tried delays and other tricks but do not really understand how I'm supposed to use viewDidAppear or viewDidDisappear to help me. Also of note is that a very basic application with one view loading the picker then displaying another view with the image in does not produce the error. Any help gratefully received.
To address the specific issue described here, you could add the viewDidAppear method in your class:
-(void)viewDidAppear:(BOOL)animated
{
if (/*just visited ImagePicker*/)
{
ImageViewController *imageViewController = [[ImageViewController alloc] init];
imageViewController.delegate = self;
[self presentModalViewController:imageViewController animated:YES];
[imageViewController release];
}
}
Remove those lines from below your call:
[picker dismissModalViewControllerAnimated:YES];
So, whenever your class self appears (is displayed), it will call viewDidAppear... Since this most likely isn't really what you want all the time, you could add some variables to set/clear that defines whether or not to immediately present the imageViewController when self is displayed. Something like "If coming from image picker, show the imageViewController, otherwise do nothing".
That said, imho, pushing modal views is should generally be done in response to a user action and I would maybe rethink the user experience here - e.g. add a subview instead of pushing a modal view which you could do where your currently have the code - but if you're just playing around with some tutorials that should solve the NSInternalInconsistencyException. :) Cheers!
In iOS 5.0 and above you can use
[self dismissViewControllerAnimated:YES completion:^{
//present another modal view controller here
}];
I ran into this issue quite a few times. I recently started using this simple fix:
When I am going to present a new modal view controller immediately after dismissing another modal view controller, I simply dismiss the first one with argument NO in dismissModalViewControllerAnimated:.
Since the second view is presented with an animation, you hardly notice that the first one goes away fast. And you never get the transitions conflict.
I was having the same problem when i wanted to present an MFMailComposeViewController immediately after dismissing the UIImagePickerController. Heres what i did:
I removed the [imagePicker release]; statement from where i was presenting the image picker and put it in didFinishPickingMedia callback.
I used [self performSelector:#selector(presentMailComposer:) withObject:image afterDelay:1.0f];
Here's my code:
Displaying Image Picker
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
NSArray *media = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
if ([media containsObject:(NSString*)kUTTypeImage] == YES) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
[picker setMediaTypes:[NSArray arrayWithObject:(NSString *)kUTTypeImage]];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
[self presentModalViewController:picker animated:YES];
//[picker release];
}
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Unavailable!"
message:#"Could not open the Photo Library."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
Image Picker Delegate Callback - didFinishPickingMedia
NSString *mediaType = [info valueForKey:UIImagePickerControllerMediaType];
if([mediaType isEqualToString:(NSString*)kUTTypeImage]) {
UIImage *photoTaken = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
//Save Photo to library only if it wasnt already saved i.e. its just been taken
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
UIImageWriteToSavedPhotosAlbum(photoTaken, self, #selector(image:didFinishSavingWithError:contextInfo:), nil);
}
//Pull up MFMailComposeView Controller
[self performSelector:#selector(composeMailWithPhoto:) withObject:photoTaken afterDelay:1.0f];
}
[picker dismissModalViewControllerAnimated:YES];
[picker release];
Display Mail Composer View
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailPicker = [[MFMailComposeViewController alloc] init];
mailPicker.mailComposeDelegate = self;
// Fill out the email fields and Attach photograph to mail
static NSString *imageType = #"image/jpeg";
NSString *imageName = [NSString stringWithString:#"MyCoffeeCup.jpg"];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
[mailPicker addAttachmentData:imageData mimeType:imageType fileName:imageName];
[mailPicker setToRecipients:[NSArray arrayWithObject:#"hello#xische.com"]];
[self presentModalViewController:mailPicker animated:YES];
//[self.navigationController pushViewController:mailPicker animated:YES];
[mailPicker release];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Unavailable!"
message:#"This device cannot send emails."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}