[英]MFMailComposeViewController not dismiss with Cancel button
[英]MFMailComposeViewController: Cancel button is not visible
我收到這個問題。 如果我單擊“取消”按鈕,則表示模態。 但是我看不到“取消”按鈕。 我認為是因為標題顏色。 但是我不確定。 請找到隨附的屏幕截圖。 而且我已經附上了代碼。
#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];
我已經更改了TitleTextAttributes的顏色。 現在工作了。
試試下面的代碼代替
[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]];
}];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.