gpt4 book ai didi

ios - iOS7 中的 MFMailComposeViewController 自定义

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:22:14 25 4
gpt4 key购买 nike

我在 iOS7 中自定义 MFMailComposeViewController 时遇到问题。我试图隐藏和删除标题,因为我有一个自定义导航外观,我想将其完全带入邮件 View Controller 。我正在使用它,它在 iOS6 上运行良好,但在 iOS7 上首次打开时无法运行。当我打开 View 并取消邮件然后再次打开 Controller 时,它会继续工作。问题是第一次出现邮件 Controller 。这是我正在使用的代码:

if ([MFMailComposeViewController canSendMail]) {

UIView* parentView = [self showProgress];

MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;

if ([[UINavigationBar class] respondsToSelector:@selector(appearance)])
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:[UIColor lightGrayColor], UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset, [UIFont fontWithName:@"CourierNewPS-BoldMT" size:1], UITextAttributeFont, [UIColor whiteColor],UITextAttributeTextColor, nil]];

[controller setToRecipients:[NSArray arrayWithObject:[LNController shared].profile.email]];
[controller setSubject:NSLocalizedString(@"APPSTORE_NAME", nil)];
NSData* energyData = [[self createEnergyCSVFile] dataUsingEncoding:NSUTF8StringEncoding];
NSData* timeData = [[self createTimeCSVFile] dataUsingEncoding:NSUTF8StringEncoding];
[controller addAttachmentData:energyData mimeType:@"text/csv" fileName:NSLocalizedString(@"ENERGY", nil)];
[controller addAttachmentData:timeData mimeType:@"text/csv" fileName:NSLocalizedString(@"TIME", nil)];

[[[[controller viewControllers] lastObject] navigationItem] setTitle:@""];
[self presentViewController:controller animated:YES completion:nil];

[self hideProgress:parentView];

}

有人经历过这个吗?任何帮助都会很棒。

最佳答案

您必须直接在 MFMailComposeViewController 上设置自定义代码。这是我的一个应用程序的示例:

if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
// Fix UI -- Add your custom UI here
[mailViewController.navigationBar setTintColor:[UIColor whiteColor]];
[mailViewController.navigationBar setBarTintColor:[UIColor whiteColor]];
// Set params
[mailViewController setToRecipients:@[@"e-mail@email.com"]];
[mailViewController setSubject:NSLocalizedString(@"Feedback", @"Feedback")];
[self presentViewController:mailViewController animated:YES completion:^{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}];
}

编辑:这是一个仅限 iOS 7 的应用程序,因此还要添加必要的检查,以免它在 iOS 6 上崩溃

关于ios - iOS7 中的 MFMailComposeViewController 自定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21850754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com