0

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.

Initial page

After clicking cancel place

#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
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Saranya Subramanian
  • 417
  • 1
  • 5
  • 19
  • try this.. `[UINavigationBar appearance].tintColor = [UIColor YourColor];` – Nirav Kotecha Jan 21 '18 at 08:44
  • I tired this but still i am facing that issue – Saranya Subramanian Jan 21 '18 at 08:45
  • try this.. maybe this one helps.. `[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor whiteColor]];` – Nirav Kotecha Jan 21 '18 at 08:46
  • look on this link.. https://stackoverflow.com/questions/19368122/cannot-set-text-color-of-send-and-cancel-buttons-in-the-mail-composer-when-prese/25531079 – Nirav Kotecha Jan 21 '18 at 08:47
  • 1
    "And I have attached the code" No, I don't think you have. You clearly have altered the appearance proxy in some way that causes this issue, but you have not shown the code where you did that. – matt Jan 21 '18 at 19:08
  • Yes @matt now found the issue. I have changed the UIBarButton appearance in AppDelete.m .. This is because of UIBarButtonItem setTitleTextAttributes ..Issue got fixed thanks – Saranya Subramanian Jan 22 '18 at 07:38
  • If the problem was solved, especially if it was solved trivially, and especially if the solution involved stuff you never even told us about in the question, please consider deleting the question. – matt Jan 22 '18 at 18:04

2 Answers2

1
    [[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 . Now it worked.

Saranya Subramanian
  • 417
  • 1
  • 5
  • 19
0

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]];
    }];
Bharath
  • 2,064
  • 1
  • 14
  • 39