简体   繁体   English

单击取消时,电子邮件编辑器不会返回

[英]email composer does not go back when i click cancel

so heres my problem i have mad an action sheet added in twitter and Facebook which work fine however when i added in an email composer it seems that the application is unable to to go back to the original screen and stays in the email composer. 所以这是我的问题,我在twitter和Facebook中添加了一个工作表,但工作正常,但是当我在电子邮件编辑器中添加应用程序时,似乎该应用程序无法返回到原始屏幕并停留在电子邮件编辑器中。

 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

//Each button title we gave to our action sheet is given a tag starting with 0.
if (buttonIndex == 0) {

    //Check Twitter accessibility and at least one account is setup.
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {

        SLComposeViewController *tweetSheet =[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

        //This is setting the initial text for our share card.
        [tweetSheet setInitialText:@"Switcher makes social networking easier, download it now from (LINK):D "];

        //Brings up the little share card with the test we have pre defind.
        [self presentViewController:tweetSheet animated:YES completion:nil];

    } else {
        //This alreat tells the user that they can't use built in socal interegration and why they can't.
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You can't send a tweet right now, make sure you have logged into twitter aleady from your iphone settings." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];
    }

}else if (buttonIndex == 1) {

    //Check Facebook accessibility and at least one account is setup.
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

        SLComposeViewController *facebookSheet =[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        //This is setting the initial text for our share card.
        [facebookSheet setInitialText:@"Switcher makes social networking easier, download it now from (LINK) :D "];

        //Brings up the little share card with the test we have pre defind.
        [self presentViewController:facebookSheet animated:YES completion:nil];

    } else {
        //This alreat tells the user that they can't use built in socal interegration and why they can't.
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You can't send a post right now, make sure you have logged into facebook aleady from your iphone settings" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];
    }

}else if (buttonIndex == 2) {

    MFMailComposeViewController *mailContoller = [[MFMailComposeViewController alloc]init];
    [mailContoller setMailComposeDelegate:self];
    NSString *email = @"";
    NSArray *emailArray = [[NSArray alloc]initWithObjects:email,nil];
    NSString *message = @"hey download my application now";
    [mailContoller setMessageBody:message isHTML:NO];
    [mailContoller setToRecipients:emailArray];
    [mailContoller setSubject:@""];
    [self presentViewController:mailContoller animated:YES completion:nil];





}

You need to implement the MFMailComposeViewControllerDelegate method. 您需要实现MFMailComposeViewControllerDelegate方法。 You need to dismiss the mail composer yourself in that method. 您需要使用该方法自行关闭邮件编辑器。

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
    [self dismissViewControllerAnimated:controller completion:nil];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我点击搜索栏上的取消时,它消失了 - When I click cancel on the searchbar it disappears 如何修复:当我在搜索栏中单击“取消”时,TableView 中的 func selectRow 不起作用 - How to fix: func selectRow in the TableView does not work when I click Cancel in search bar 当我单击更多按钮而不是我离开的VC时,如何返回iOS中MOre…按钮的“表格” - How can I go back to the “Table” of a MOre… button in iOS when I click the more button and not the VC I left from 当我回到它时,UIViewController得到偏移 - UIViewController gets offset when I go back to it popViewController不返回 - popViewController does not go back 取消与UITableViewCells关联的NSTimers,当它们离开屏幕时 - Cancel NSTimers associated with UITableViewCells when they go offscreen iOS:在“消息”应用中点按“取消”以返回调用它的应用 - iOS: Tap cancel in Messages app to go back to app that invoked it 当我返回时,ViewController失去了其属性 - ViewController loses its properties when I go back 当我回到视图控制器时刷新 tableview 顶部的控件 - Refresh Control on top of tableview when I go back to view controller 当我返回菜单时,应用程序崩溃(线程 1:信号 SIGABRT) - When I go back to menu, the App crashes (Thread 1: signal SIGABRT)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM