0

我使用来自 Github 的 JTRevealSidebar。当我单击左侧边栏中的一个单元格(反馈)时我遇到了问题,我想打开 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];
            });

        }
    }

}
4

1 回答 1

1

首先,您应该关闭您所在的视图控制器。这是因为侧边栏本身就是一个视图控制器。然后显示 mailController,使其显示在中心视图控制器中。

代码更改:

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

改用这个:

[self dismissViewControllerAnimated:YES completion:nil];
于 2013-05-11T14:46:57.927 回答