0

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

我的代码是:

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];
4

1 回答 1

1

MFMailComposeViewController而相关的 Facebook 和 Twitter 共享视图在 iOS 6 中是通过远程视图控制器实现的。这意味着控制器运行在另一个进程中,不再可以通过直接访问它们的属性或子视图来自定义它们。不过,您仍然可以这样做UIAppearence,但是在 iOS 6 中,您尝试替换按钮的操作不再可行。

于 2013-06-05T11:47:41.927 回答