[英]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.