简体   繁体   English

MFMailComposeViewController:取消按钮不可见

[英]MFMailComposeViewController: Cancel button is not visible

I am getting this issue. 我收到这个问题。 If I click the cancel button place am getting the modal. 如果我单击“取消”按钮,则表示模态。 But I am not able to see the cancel button. 但是我看不到“取消”按钮。 I think it is because of title color. 我认为是因为标题颜色。 But I am not sure. 但是我不确定。 Please find the attached screenshots. 请找到随附的屏幕截图。 And I have attached the code. 而且我已经附上了代码。

初始页

单击取消位置后

#import "SupportControllerViewController.h"
#import <MessageUI/MFMailComposeViewController.h>

@interface SupportControllerViewController ()

@end

@implementation SupportControllerViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    UITapGestureRecognizer *mailUsTab = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mailUs)];
    mailUsTab.numberOfTapsRequired=1;
    mailUsTab.delegate=self;
    [self.rightView addGestureRecognizer:mailUsTab];
}

- (IBAction)backBtn:(id)sender {
    [self.navigationController dismissViewControllerAnimated:YES completion:^{
    }];
}

- (void)mailUs {
    if (![MFMailComposeViewController canSendMail]) {
        NSLog(@"Mail services are not available.Please check your mail app.");
        return;
    }
    {
    MFMailComposeViewController *mailcontroller = [[MFMailComposeViewController alloc] init];
    mailcontroller.mailComposeDelegate = self;
    //mailcontroller.delegate = self;
    [self presentViewController:mailcontroller animated:YES completion:nil];
    }
}

- (void)mailComposeController:(MFMailComposeViewController*)controller
      didFinishWithResult:(MFMailComposeResult)result
                    error:(NSError*)error;
{
    NSLog(@"Coming here");
    if (result == MFMailComposeResultSent) {
        [self.view makeToast:@"We have received your mail.We will contact you as soon as possible"
                duration:3.0
                position:CSToastPositionCenter];
    }

    if (result == MFMailComposeResultFailed) {
         [self.view makeToast:@"Some error has occurred.Please check your internet connection."
                duration:3.0
                position:CSToastPositionCenter];
    }
    if(result == MFMailComposeResultCancelled){
    }
    if(result == MFMailComposeResultSaved){
    }
    [controller dismissViewControllerAnimated:YES completion:nil];
    return;
}

@end
    [[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                      [UIColor whiteColor],NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
    [[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                      [UIColor whiteColor],NSForegroundColorAttributeName, nil] forState:UIControlStateHighlighted];

I have changed the TitleTextAttributes color . 我已经更改了TitleTextAttributes的颜色。 Now it worked. 现在工作了。

Try the following code instead of, 试试下面的代码代替

[self presentViewController:mailcontroller animated:YES completion:nil];

Try this, 尝试这个,

[self presentViewController:mailcontroller animated:YES completion:^{
        [[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]]; // Choose color as per your preference.
        [[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
    }];

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

相关问题 MFMailComposeViewController不能通过“取消”按钮关闭 - MFMailComposeViewController not dismiss with Cancel button MFMailComposeViewController取消和发送按钮未显示 - MFMailComposeViewController cancel and send button not seen MFMailComposeViewController-更改取消并向图像发送按钮 - MFMailComposeViewController - change cancel and send button to images 如何访问按钮发送,在MFMailComposeViewController中取消 - how to access on button send, cancel in MFMailComposeViewController MFMailComposeViewController iOS 上缺少取消和发送按钮 - Cancel and send button missing on MFMailComposeViewController iOS 取消按钮在MFMailComposeViewController - iOS 8中不执行任何操作 - Cancel button does nothing in MFMailComposeViewController - iOS 8 iOS 8:MFMailComposeViewController自动调用取消按钮 - iOS 8 :MFMailComposeViewController automatic called cancel button 如何为MFMailComposeViewController对象的“取消”按钮修改操作表的样式 - How to modify the style of the action sheet for MFMailComposeViewController object's cancel button MFMailComposeViewController的代表未处理“取消”按钮或iOS 4.x及更早版本 - MFMailComposeViewController's delegate not handling the 'Cancel' button or iOS 4.x and earlier MFMailComposeViewController的取消按钮(可能是操作表)冻结视图 - MFMailComposeViewController's Cancel Button (action sheet possibly) freezes the view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM