MFMessageComposeViewController

MFMessageComposeViewController

本文介绍了MFMessageComposeViewController 的收件人字段未显示在 iOS 7 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在 iOS 5/6 中运行良好.在 iOS 7 中,它看起来像这样(红色椭圆形强调).

The code below works fine in iOS 5/6. In iOS 7, it looks like this (red oval for emphasis).

代码:

if ([MFMessageComposeViewController canSendText]) {
    self.messageComposer = [MFMessageComposeViewController new];
    self.messageComposer.recipients = @[number];
    self.messageComposer.messageComposeDelegate = self;
    [self presentViewController:self.messageComposer
                       animated:YES
                     completion:nil];
}

问题:这是简单的代码.是否有其他一些外部属性,可能是呈现视图控制器的,影响了这一点?任何人都有修复或解决方法?

Question: This is simple code. Is there some other external property, perhaps of the presenting view controller, that is affecting this? Anyone have a fix or workaround?

谢谢.

推荐答案

我发现 MFMessageComposeViewController 的收件人字段似乎从 iOS7 中的 UINavigationBar 外观代理中获得了一些外观.为了解决这个问题,我在我的应用中执行了以下操作:

I've found that the MFMessageComposeViewController's recipient field seems to take some of it's appearance from the UINavigationBar appearance proxy in iOS7. To work around this, I've done the following in my apps:

  1. 创建一个空的自定义 UINavigationController 子类,它不会覆盖任何 UINavigationController 的方法.

  1. Create an empty custom UINavigationController subclass, which doesn't override any of UINavigationController's methods.

通过在 IB 中的身份检查器上设置自定义类,将此自定义 UINavigationController 子类用作我想要具有自定义外观的任何导航控制器的标记:

Use this custom UINavigationController subclass as a marker for any navigation controllers that I want to have custom appearance, by setting the custom class on the identity inspector in IB:

在我的应用委托中,像这样设置导航栏的外观:

In my app delegate, set up the appearance of navigation bars like this:

 [[UINavigationBar appearanceWhenContainedIn:[MyCustomNavigationController class], nil] ...];

这可确保我在要自定义的控制器中获得所需的导航栏外观,但在其他控制器(如 MFMessageComposeViewController)中保留标准导航栏(和相关)外观.这是一个屏幕截图;请注意 MFMessageComposeViewController 的标准外观,以及背景中弹出窗口上的自定义导航栏外观:

This ensures that I get the navigation bar appearance I want in the controllers I want to customize, but preserves the standard navigation bar (and related) appearance in other controllers (like MFMessageComposeViewController). Here's a screenshot; note the standard appearance of MFMessageComposeViewController, with the custom navigation bar appearance on the popover in the background:

这篇关于MFMessageComposeViewController 的收件人字段未显示在 iOS 7 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 15:00