[objective-c]MailComposer 在侧边栏中打开

标签: ios Objective-C
发布时间: 2016/10/2 12:05:18
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

我使用从 Github JTRevealSidebar。我有问题,当我点击左边的 Sidebar(Feedback) 我想要打开的 MailComposer 中的单元格。MailComposer 是开放而是仅在左侧边栏。谁能帮我吗?

enter code here

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    /*if (self.sidebarDelegate) {
        NSObject *object = [NSString stringWithFormat:@"ViewController%d", indexPath.row];
        [self.sidebarDelegate sidebarViewController:self didSelectObject:object atIndexPath:indexPath];
    }*/

    if(indexPath.section == 0){
        if(indexPath.row == 1){ // Feedback{
            MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
            mailController.mailComposeDelegate = self;

            [mailController setSubject:@"Feedback für testapp"];
            // Fill out the email body tex
            NSString *emailBody = [NSString stringWithFormat:@"\n\n\n\nApp: %@ \n App-Version: %@ \nModel: %@ \n Version: %@",
                                   @"TestApp",
                                   [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"],
                                   [UIDevice currentDevice].model,
                                   [UIDevice currentDevice].systemVersion];
            [mailController setMessageBody:emailBody isHTML:NO];
            [mailController setToRecipients:[NSArray arrayWithObjects:@"support@testapp.com",nil]];

            dispatch_async(dispatch_get_main_queue(), ^{
                // whatever code you want to run on the main thread
                [self presentModalViewController:mailController animated:YES];
            });

        }
    }

}

解决方法 1:

首先你应该解雇你是在 viewcontroller。这是因为侧边栏是 viewcontroller 在其自身上。然后呈现 mailController,以便它显示在中心 viewcontroller。

更改代码︰

dispatch_async(dispatch_get_main_queue(), ^{
 [self dismissModalViewController];
 [self presentModalViewController:mailController animated:YES];
});

而使用以下代码︰

[self dismissViewControllerAnimated:YES completion:nil];
官方微信
官方QQ群
31647020