In my app i am having 7 button i am show 3 button in that view after pressing down arrow it show other 3 button
1.Facebook share
2.twitter share
3.tell a friend
4.report
5.starter guide
6.visit my web site
7. feed back
LIKE THIS MY VIEW
====================
^ ---->up arrow
facebook share
Twitter share
Tell a friend
V ---->down arrow
i am using mailcomposerview for "tell a friend" button and "report" button
when i press "Tell a Friend" or "report" button it opens mailcomposerview after closing that i am not able to move the up and down arrow......if i press the up and down arrow it open the same mail composerview,its also not opening facebook share and twitter share
please help me to fix this issue
my coding when arrow pressed
-(void)arrTapped1:(id)sender
{
CCMenuItem *item2=(CCMenuItem*)sender;
int k=item2.tag;
////CCLOG(#"k tapp=%dhelp=%d",k,helpVal);
NSLog(#"HelpVal%i",helpVal);
if(k==51)
{
if(helpVal<3)
{
id action1=[CCMoveBy actionWithDuration:0.3 position:ccp(0,+260)];
id callfun1=[CCCallFunc actionWithTarget:self selector:#selector(enabled1) ];
[item2 setIsEnabled:YES];
[(CCSprite*)[self getChildByTag:10] runAction:[CCSequence actions:action1,callfun1,nil]];
[self performSelector:#selector(downWardsMove)];
}
}
else //if(k==50)
{
if(helpVal>1)
{
id action1=[CCMoveBy actionWithDuration:0.3 position:ccp(0,-260)];
id callfun1=[CCCallFunc actionWithTarget:self selector:#selector(enabled1) ];
[item2 setIsEnabled:YES];
[(CCSprite*)[self getChildByTag:10] runAction:[CCSequence actions:action1,callfun1,nil]];
[self performSelector:#selector(upWardsMove)];
} } }
//code for upwards & downwards move
//--------------------------------
-(void)upWardsMove
{
[upArrItem setIsEnabled:NO];
[downArrItem setIsEnabled:NO];
self.isTouchEnabled=NO;
helpVal--;
[(CCMenu*)[self getChildByTag:53] setVisible:YES];
[downArrItem setIsEnabled:YES];
if(helpVal==1)
{
[(CCMenu*)[self getChildByTag:52] setVisible:NO];
[upArrItem setIsEnabled:NO];
}
}
-(void)downWardsMove
{
[upArrItem setIsEnabled:NO];
[downArrItem setIsEnabled:NO];
self.isTouchEnabled=NO;
helpVal++;
[(CCMenu*)[self getChildByTag:52] setVisible:YES];
[upArrItem setIsEnabled:YES];
if(helpVal==3){
[(CCMenu*)[self getChildByTag:53] setVisible:NO];
[downArrItem setIsEnabled:NO];
}
}
-(void)enabled1
{
self.isTouchEnabled=YES;
[upArrItem setIsEnabled:YES];
[downArrItem setIsEnabled:YES];
if(helpVal==3)
{
[(CCMenu*)[self getChildByTag:53] setVisible:NO];
[downArrItem setIsEnabled:NO];
}
if(helpVal==1)
{
[(CCMenu*)[self getChildByTag:52] setVisible:NO];
[upArrItem setIsEnabled:NO];
}
}
//sending mail code
//------------------
-(void)sendMail
{
mailComposer = [[UIViewController alloc] init];
[[[CCDirector sharedDirector] openGLView] addSubview:mailComposer.view];
MFMailComposeViewController *mailController= [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setSubject:msgSubject];
[mailController setMessageBody:mailContent isHTML:YES];
NSArray *toRecipients = [NSArray arrayWithObject:#"Info#ask.com"];
[mailController setBccRecipients:toRecipients];
[mailComposer presentModalViewController:mailController animated:NO];
mailComposer.view.transform = CGAffineTransformMakeRotation( CC_DEGREES_TO_RADIANS(90.0f ) );
[mailController release];
[[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight]
}
-(void)mailComposeController:(MFMailComposeViewController*)mailController didFinishWithResult: (MFMailComposeResult)result error:(NSError*)error
{
[mailComposer dismissModalViewControllerAnimated:YES];
}
Here is a part of a code that I used in my apps and it works well in iOS 4.0 - iOS 6.0. Take a look:
-(void)sendMessageToEmail:(NSString *)message withSubject:(NSString *)subject
{
if([self _isIOS6andHigher]) {
NSArray *activities = #[message];
UIActivityViewController *viewController = [[UIActivityViewController alloc] initWithActivityItems:activities applicationActivities:nil];
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[[app navController] presentViewController:viewController animated:YES completion:nil];
[viewController release];
} else {
MFMailComposeViewController* mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setSubject:subject];
[mailController setMessageBody:message isHTML:NO];
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[[app navController] presentModalViewController:mailController animated:YES];
[mailController release];
}
}
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
[controller dismissModalViewControllerAnimated:YES];
}
You never release mailComposer:
mailComposer = [[UIViewController alloc] init];
This might cause it to leak and remain active as a view. That could explain the lack of touch events because mail composer might still intercept touches.
Related
Edit - I solved this myself - see the notes at the bottom
When using iOS7 on Xcode 5, I am using an option to take an image from a camera, or from the photo library, once the image is chosen (or a new picture taken) the view should flip over to the next screen.
This does not happen on the iPhone running iOS7, it works fine on the iPad, but the method is slightly different, but it does appear to be iPhone only problem on iOS7.
here is the code used, for example, on the choose image from library function;
-(void) choosePic {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeSavedPhotosAlbum];
cameraUI.allowsEditing = NO;
cameraUI.delegate = self;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
_popover = [[UIPopoverController alloc] initWithContentViewController:cameraUI];
[_popover presentPopoverFromRect:btnLibrary.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else
[self presentModalViewController: cameraUI animated: YES];
}
}
Also, the code once picker is finished;
- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {
//Disable buttons
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[self disableButtons];
//Get image
self.originalImage = (UIImage *) [info objectForKey: UIImagePickerControllerOriginalImage];
//Dismiss
if(_popover)
{
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
[_popover dismissPopoverAnimated:YES];
_popover = nil;
}
}
else
[picker dismissModalViewControllerAnimated: YES];
//Next
[self performSelector: #selector(nextScreen) withObject:nil afterDelay:0.5];
}
I fixed this by switching out;
[picker dismissModalViewControllerAnimated: YES];
With
[picker dismissViewControllerAnimated:NO completion:nil];
First you need to make sure that logic reaches the correct place it's intended to, try setting a breakpoint or NSLog before the iPhone's specific line, try this (You also missed curled braces, added them here) :
-(void) choosePic {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeSavedPhotosAlbum];
cameraUI.allowsEditing = NO;
cameraUI.delegate = self;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
_popover = [[UIPopoverController alloc] initWithContentViewController:cameraUI];
[_popover presentPopoverFromRect:btnLibrary.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}else{
NSLog(#"Checkpoint !");
[self presentModalViewController: cameraUI animated: YES];
}
} }
I want to determine it a user is signed on to twitter, so I can prompt them to post a tweet but only if they are set up with ios and twitter. Also, is there a way to set up the twitter screen with a default tweet?
For iOS 5.x, you can check if the user is signed in to twitter using:
[TWTweetComposeViewController canSendTweet]
As for presenting a tweet screen with default message, you can do something like:
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:defaultMsg];
[self presentModalViewController:tweetSheet animated:YES];
You can refer this tutorial for more.
EDIT: For iOS 6.0 and above, use:
// requires "Social.framework"
[SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]
So, an example usage could be:
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler = myBlock;
[controller setInitialText:#"#myHashTag"];
[controller addImage:myImage];
[self presentViewController:controller animated:YES completion:Nil];
}
else
{ /* Show error alert, etc*/ }
Further reading
As I said in my comment if you are using IOS 5 or later versions just add Twitter.framework to your projects
#import <Twitter/Twitter.h>
//post tweets
- (IBAction)postTapped:(id)sender{
if ([TWTweetComposeViewController canSendTweet])
{
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:#" #hashtag"];
[self presentModalViewController:tweetSheet animated:YES];
}
else
{
TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc] init];
//hide the tweet screen
viewController.view.hidden = YES;
//fire tweetComposeView to show "No Twitter Accounts" alert view on iOS5.1
viewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
if (result == TWTweetComposeViewControllerResultCancelled) {
[self dismissModalViewControllerAnimated:NO];
}
};
[self presentModalViewController:viewController animated:NO];
//hide the keyboard
[viewController.view endEditing:YES];
}
}
I'm trying to write code to select an image from the photo library on an iPad. The code that I'm using is below (taken from Apple's website), but it keeps giving me an error saying that On iPad, UIImagePickerController must be presented via UIPopoverController. I've tried changing this line: UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init]; to use a UIPopoverController, but obviously I'm doing something wrong because its not working.
- (BOOL) selectImage: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate {
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)
|| (delegate == nil)
|| (controller == nil))
return NO;
UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
mediaUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
// Displays saved pictures and movies, if both are available, from the
// Camera Roll album.
mediaUI.mediaTypes =
[UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypeSavedPhotosAlbum];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
mediaUI.allowsEditing = NO;
mediaUI.delegate = delegate;
[controller presentModalViewController: mediaUI animated: YES];
return YES; }
The Apple Developer page also says: "On iPad, you can alternatively present the browser interface using a popover as described in initWithContentViewController: and “Presenting and Dismissing the Popover” in UIPopoverController Class Reference." I've read it but I still can't get it to work. Any help would be appreciated.
Something like this should work:
// create an image picker controller
UIImagePickerController *imagePickerController = [[[UIImagePickerController alloc] init] autorelease];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
imagePickerController.delegate = self;
// present it in a popover
self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:imagePickerController] autorelease];
self.popoverController.delegate = self;
// I was presenting the popover from a button, but you would set the rect to whatever is appropriate for your app
[self.popoverController presentPopoverFromRect:((UIButton *)sender).bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Declare an ivar such as:
UIPopoverController *imagePopover;
Then:
imagePopover = [[UIPopoverController alloc] initWithContentViewController:mediaUI];
[imagePopover setDelegate:self];
[imagePopover presentPopoverFromRect:someRect
inView:someView
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
in place of
[controller presentModal...];
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 400.0, 400.0)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
refer below link
http://www.techotopia.com/index.php/An_Example_iOS_4_iPad_Camera_and_UIImagePickerController_Application_%28Xcode_4%29
I went through a lot of pain coming up with a solution which works on both iPad and iPhone, this is the final code which some of it comes from comments of other people:
the code has some bugs but it's a very good place to start :)
it covers permissions needed as well as how to manage viewcontrollers popoing up on ipad.
requires following imports :
#import <AVFoundation/AVFoundation.h>
#import <AssetsLibrary/AssetsLibrary.h>
and add this delegates :
UIActionSheetDelegate, UIImagePickerControllerDelegate
definitions :
__weak IBOutlet UIButton *attachButton;
UIImage *image;
button's action :
- (IBAction)doAttach:(id)sender {
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:#"Select image from" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:#"From library",#"From camera", nil] ;
[action showInView:self.view];
}
#pragma mark - ActionSheet delegates
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if( buttonIndex == 1 ) {
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if(authStatus == AVAuthorizationStatusAuthorized)
{
NSLog(#"%#", #"You have camera access");
}
else if(authStatus == AVAuthorizationStatusDenied)
{
NSLog(#"%#", #"Denied camera access");
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if(granted){
NSLog(#"Granted access to %#", AVMediaTypeVideo);
} else {
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:#“no camera access“
message: #“if you need to use camera in this application go to settings -> appName -> and turn on camera.”
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:#“ok” style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
NSLog(#"Not granted access to %#", AVMediaTypeVideo);
return ;
}
}];
}
else if(authStatus == AVAuthorizationStatusRestricted)
{
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:#“no camera access“
message: #“if you need to use camera in this application go to settings -> appName -> and turn on camera.”
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:#“ok” style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
NSLog(#"%#", #"Restricted, normally won't happen");
}
else if(authStatus == AVAuthorizationStatusNotDetermined)
{
NSLog(#"%#", #"Camera access not determined. Ask for permission.");
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if(granted){
NSLog(#"Granted access to %#", AVMediaTypeVideo);
} else {
NSLog(#"Not granted access to %#", AVMediaTypeVideo);
return ;
}
}];
}
else
{
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:#“No camera access“
message: #“error accusing camera”
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:#“ok” style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
return;
//NSLog(#"%#", #"Camera access unknown error.");
}
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *pickerView =[[UIImagePickerController alloc]init];
pickerView.allowsEditing = YES;
pickerView.delegate = self;
pickerView.sourceType = UIImagePickerControllerSourceTypeCamera;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[ self.presentedViewController dismissViewControllerAnimated:YES completion:nil ];
pickerView.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popPC = pickerView.popoverPresentationController;
popPC.sourceView = attachButton;
popPC.permittedArrowDirections = UIPopoverArrowDirectionAny;
[self presentViewController:pickerView animated:YES completion:nil];
} else {
[self presentModalViewController:pickerView animated:YES ];
}
}
}else if( buttonIndex == 0 ) {
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
switch (status) {
case ALAuthorizationStatusRestricted:
case ALAuthorizationStatusDenied:
{
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:#“no access to library”
message: #“if you wish to access photos in this app go to settings -> appName-> and turn on photos .”
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:#“ok” style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
}
break;
default:
{
UIImagePickerController *pickerView = [[UIImagePickerController alloc] init];
pickerView.allowsEditing = YES;
pickerView.delegate = self;
[pickerView setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[ self.presentedViewController dismissViewControllerAnimated:YES completion:nil ];
pickerView.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popup = pickerView.popoverPresentationController;
popup.sourceView = attachButton;
popup.permittedArrowDirections = UIPopoverArrowDirectionAny;
[self presentViewController:pickerView animated:YES completion:nil];
} else {
[self presentModalViewController:pickerView animated:YES ];
}
}
break;
}
}
}
#pragma mark - PickerDelegates
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[self dismissModalViewControllerAnimated:true];
UIImage * img = [info valueForKey:UIImagePickerControllerEditedImage];
image = img;
}
#interface ViewController : UIViewController { //....yor variables }
in ViewController.m file:
(void)viewDidLoad {
[super viewDidLoad];
self.title = #"Sample Email Application"; // title of navigation bar
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:#selector(composeMail:)] autorelease]; // for adding a compose button //in navigation bar. //...your code }
-(void) composeMail: (id) sender{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc]init];
picker.mailComposeDelegate = self;
[[picker navigationBar] setTintColor:[UIColor blackColor]];
[picker setSubject:#"Sample Email Application"];
[picker setMessageBody:[NSString stringWithFormat:#"Visit for more help %#. ",#"http://google.com"] isHTML:YES];
[self presentModalViewController:picker animated:YES];
[picker release];
}
-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
[controller dismissModalViewControllerAnimated:YES];
}
It looks like you are missing the -setToRecipients, which you can't send mail unless you have an address to send to.
[picker setToRecipients:[NSArray arrayWithObjects:#"your#emailstring.com", nil]];
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:#"name#gmail.com",nil]];
[picker setSubject:#"Sample"];
}
[self.view addSubview:picker.view];
[self presentModalViewController:picker animated:YES];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissModalViewControllerAnimated:YES];
}
You are presenting the mail composer twice.
Remove the line:
[self.view addSubview:picker.view];
And replace the next line with:
[self.navigationController presentModalViewController:picker animated:YES];
If you are adding only subview of mailcomposser you have to remove it from self.view,
In your code you are adding subview and present also,
If you are use only use [self.view addSubview:picker.view]; than
Try with to remove it.
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[controller.view removeFromSuperview];
}
I'm still suggest to use
[self.navigationController presentModalViewController:picker animated:YES]; for Present MFMailComposeViewController ,
and use [self dismissModalViewControllerAnimated:YES]; to dismiss it.
Use this code:
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObjects:#"niftyapplications#gmail.com", #"support#niftysol.com", nil];
[controller setToRecipients:toRecipients];
[controller setTitle:#"Contact Us"];
controller.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:controller animated:YES];
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self becomeFirstResponder];
NSString *strMailResult;
switch (result)
{
case MFMailComposeResultCancelled:
strMailResult = NSLocalizedString(#"E-Mail Cancelled",#"");
break;
case MFMailComposeResultSaved:
strMailResult = NSLocalizedString(#"E-Mail Saved",#"");
break;
case MFMailComposeResultSent:
strMailResult = NSLocalizedString(#"E-Mail Sent",#"");
break;
case MFMailComposeResultFailed:
strMailResult = NSLocalizedString(#"E-Mail Failed",#"");
break;
default:
strMailResult = NSLocalizedString(#"E-Mail Not Sent",#"");
break;
}
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(#"ISO Audit",#"") message:strMailResult delegate:self cancelButtonTitle:NSLocalizedString(#"OK",#"") otherButtonTitles:nil];
[alertView show];
[self dismissModalViewControllerAnimated:YES];
}
Set Delegate of MFMailComposeViewController
MFMailComposeViewController *mailcomposer = [[MFMailComposeViewController alloc]init];
mailcomposer.mailComposeDelegate = self;
And Use this Delegate Method
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
}