簡體   English   中英

單擊取消時,電子郵件編輯器不會返回

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

所以這是我的問題,我在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];





}

您需要實現MFMailComposeViewControllerDelegate方法。 您需要使用該方法自行關閉郵件編輯器。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM