gpt4 book ai didi

ios - MFMailComposeViewController 自定义

转载 作者:行者123 更新时间:2023-11-29 03:52:27 25 4
gpt4 key购买 nike

我正在自定义 MFMailComposeViewController,它在 ios 5.0 和 ios 5.1 中工作正常,但在 ios 6 中无法正常工作。自定义发送和取消按钮不会出现在邮件 Controller 中。

我的代码是:

sendBtn = mailer.navigationBar.topItem.rightBarButtonItem;
cancelBtn = mailer.navigationBar.topItem.leftBarButtonItem;
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigation.png"] forBarMetrics:UIBarMetricsDefault];

UINavigationItem *mailVCNavItem = [mailer.navigationBar.items objectAtIndex:0];

// Get the old bar button item to fetch the action and target.
UIBarButtonItem *oldCancelBarButton = [mailVCNavItem leftBarButtonItem];

// Create your new custom bar button item.
// In my case I have UIButton with image set as a custom view within a bar button item.
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[backButton setImage:[UIImage imageNamed:@"cancel-button-hover.png"] forState:UIControlStateNormal];
[backButton addTarget:oldCancelBarButton.target action:oldCancelBarButton.action forControlEvents:UIControlEventTouchUpInside];
[backButton setFrame:CGRectMake(0, 0, 55, 28)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];

UIButton *sendbtn = [UIButton buttonWithType:UIButtonTypeCustom];
[sendbtn setImage:[UIImage imageNamed:@"send-btnComment.png"] forState:UIControlStateNormal];
[sendbtn addTarget:self action:@selector(sendMail:) forControlEvents:UIControlEventTouchUpInside];
[sendbtn setFrame:CGRectMake(0, 0, 55, 28)];
self.navigationItem.rightBarButtonItem =[[UIBarButtonItem alloc] initWithCustomView:sendbtn];

最佳答案

MFMailComposeViewController 以及相关的 Facebook 和 Twitter 共享 View 是通过 iOS 6 中的远程 View Controller 实现的。这意味着 Controller 在另一个进程中运行,不再可以通过访问来自定义它们直接使用它们的属性或 subview 。不过,您仍然可以通过 UIAppearence 执行此操作,但您尝试替换按钮的操作在 iOS 6 中不再可行。

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

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