【问题标题】:MFMailComposeViewController: Cancel button is not visibleMFMailComposeViewController:取消按钮不可见
【发布时间】:2018-01-21 08:32:43
【问题描述】:

我遇到了这个问题。如果我单击取消按钮,则会出现模态。但我看不到取消按钮。我认为这是因为标题颜色。但我不确定。请找到随附的屏幕截图。我附上了代码。

#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

【问题讨论】:

  • 试试这个..[UINavigationBar appearance].tintColor = [UIColor YourColor];
  • 我厌倦了这个,但我仍然面临这个问题
  • 试试这个..也许这个有帮助..[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor whiteColor]];
  • "我附上了代码" 不,我不认为你有。您显然已经以某种方式更改了导致此问题的外观代理,但您没有显示您所做的代码。

标签: ios objective-c mfmailcomposeviewcontroller


【解决方案1】:
    [[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                      [UIColor whiteColor],NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
    [[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                      [UIColor whiteColor],NSForegroundColorAttributeName, nil] forState:UIControlStateHighlighted];

我更改了 TitleTextAttributes 颜色。现在它起作用了。

【讨论】:

  • 我需要在哪里添加此代码??因为它不适合我。
  • 不适合我。它唯一的第一次工作然后关闭邮件视图然后打开它不工作
【解决方案2】:

试试下面的代码,而不是,

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

试试这个,

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多