一个关于MFMessageComposeViewController的ios7中的诡异有关问题 收件人视图黑色 和解决方式

一个关于MFMessageComposeViewController的ios7中的诡异问题 收件人视图黑色 和解决方式
当使用 
UIImage *img = [UIImage imageNamed:@"navigation-bar-bg"];// navi_stretch_bg
    img = [img 
resizableImageWithCapInsets:UIEdgeInsetsMake(2120)];
    [[
UINavigationBar appearancesetBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
后,
弹出的MFMessageComposeViewController 的界面, 短信收件人视图,竟然,先出现再消失,真是奇怪!!!

一个关于MFMessageComposeViewController的ios7中的诡异有关问题 收件人视图黑色 和解决方式
一个关于MFMessageComposeViewController的ios7中的诡异有关问题 收件人视图黑色 和解决方式一个关于MFMessageComposeViewController的ios7中的诡异有关问题 收件人视图黑色 和解决方式
如果不加那句的话,显示就是正常的
一个关于MFMessageComposeViewController的ios7中的诡异有关问题 收件人视图黑色 和解决方式


搜索了下,看到网上也有人遇到了同样的问题
http://www.cocoachina.com/ask/questions/show/109921/MFMessageComposeViewController黑块遮盖发送人
从应用中弹出MFMessageComposeViewController的时候,能看到发送目标手机号一瞬间,然后就被一个黑块盖住了

http://www.blogosfera.co.uk/2013/09/mfmessagecomposeviewcontroller-shows-blank-white-screen-in-ios7/
搜索的关键字
Recipients field of MFMessageComposeViewController doesn't show in iOS 7

分析原因:
在IOS7中,MFMessageComposeViewController中的,Recipients field of MFMessageComposeViewController的行为,会读取设置的UINavigationController 的行为,至于苹果为什么这么做,实在是弄不懂
解决方式 
http://*.com/questions/19105591/recipients-field-of-mfmessagecomposeviewcontroller-doesnt-show-in-ios-7
本来我们设置
    UIImage *img = [UIImage imageNamed:@"navigation-bar-bg"];// navi_stretch_bg
    img = [img 
resizableImageWithCapInsets:UIEdgeInsetsMake(2120)];
    [[
UINavigationBar appearancesetBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
这样就影响了全局的UINavigationBar   想了很多办法
比如 [[UINavigationBar appearanceWhenContainedIn:[MFMessageComposeViewController class], nilsetBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; 按理说应该起作用,但是实际上是不起作用

组后解决的办法是
不设置全局的[UINavigationBar appearance]  而是,对于我们app中使用到的UINavigationController 换成
@interface MLNavigationController : UINavigationController
@end


MLNavigationController *nav = [[MLNavigationController alloc]initWithRootViewController:self.viewController];

然后设置
    UIImage *img = [UIImage imageNamed:@"navigation-bar-bg"];// navi_stretch_bg
    img = [img 
resizableImageWithCapInsets:UIEdgeInsetsMake(2120)];
    
//[[UINavigationBar appearance] setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
    [[
UINavigationBar appearanceWhenContainedIn:[MLNavigationController class], nilsetBackgroundImage:img forBarMetrics:UIBarMetricsDefault];


这样,就避免了MFMessageComposeViewController  中的UINavigationBar  受到影响,也就解决了问题了



顺便提一下
当你的MFMessageComposeViewController   弹出后,显示的是如下这样的
一个关于MFMessageComposeViewController的ios7中的诡异有关问题 收件人视图黑色 和解决方式
一个关于MFMessageComposeViewController的ios7中的诡异有关问题 收件人视图黑色 和解决方式
你想换掉这个绿色,也是用上面的类似方法,直接设置 
MFMessageComposeViewController *messageVC = [[MFMessageComposeViewController allocinit];
    
    messageVC.
body = @"Test";
    
//messageVC.recipients = @[@"+31646204287"];
    messageVC.
recipients = @[@"106582530201"];
    messageVC.
messageComposeDelegate = self;
    
UINavigationBar *navibar = messageVC.navigationBar;
    
    navibar.
barTintColor = [UIColor whiteColor];
    [
self presentViewController:messageVC animated:NO completion:NULL];
是没用的

只能是
        UINavigationBar *navibar = [UINavigationBar appearanceWhenContainedIn:[ZAViewController  class], nil];
        navibar.
barTintColor = UIColorFromRGB(0x3cd66f);// RGBACOLOR(0x00, 0xbe, 0xbc, 0.7);//[UIColor colorWithHexString:@"#00abb8"];
        
//[[UIBarButtonItem appearance] setTintColor:RGB(0x00, 0xab, 0xb8, 0.7)];
        [navibar 
setTintColor:[UIColor whiteColor]];//这个可以决定系统返回按钮的返回的箭头的颜色
        
        [navibar 
setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor whiteColorforKey:NSForegroundColorAttributeName]];


这样的话,全局设置的UINavigationBar  就不会影响 MFMessageComposeViewController  中的了