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

当使用 
UIImage  *img = [ UIImage   imageNamed : @"navigation-bar-bg" ]; // navi_stretch_bg
    img = [img 
resizableImageWithCapInsets : UIEdgeInsetsMake ( 2 1 2 0 )];
    [[
UINavigationBar   appearance setBackgroundImage :img  forBarMetrics : UIBarMetricsDefault ];
后,
弹出的MFMessageComposeViewController 的界面, 短信收件人视图,竟然,先出现再消失,真是奇怪!!!



如果不加那句的话,显示就是正常的



搜索了下,看到网上也有人遇到了同样的问题
从应用中弹出MFMessageComposeViewController的时候,能看到发送目标手机号一瞬间,然后就被一个黑块盖住了

搜索的关键字
Recipients field of MFMessageComposeViewController doesn't show in iOS 7

分析原因:
在IOS7中,MFMessageComposeViewController中的,Recipients field of MFMessageComposeViewController的行为,会读取设置的 UINavigationController 的行为,至于苹果为什么这么做,实在是弄不懂
解决方式 
本来我们设置
     UIImage  *img = [ UIImage   imageNamed : @"navigation-bar-bg" ]; // navi_stretch_bg
    img = [img 
resizableImageWithCapInsets : UIEdgeInsetsMake ( 2 1 2 0 )];
    [[
UINavigationBar   appearance setBackgroundImage :img  forBarMetrics : UIBarMetricsDefault ];
这样就影响了全局的 UINavigationBar    想了很多办法
比如  [[ UINavigationBar   appearanceWhenContainedIn :[ MFMessageComposeViewController   class ],  nil setBackgroundImage : 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 ( 2 1 2 0 )];
    
//[[UINavigationBar appearance] setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
    [[
UINavigationBar   appearanceWhenContainedIn :[ MLNavigationController   class ],  nil setBackgroundImage :img  forBarMetrics : UIBarMetricsDefault ];


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



顺便提一下
当你的 MFMessageComposeViewController    弹出后,显示的是如下这样的


你想换掉这个绿色,也是用上面的类似方法,直接设置 
MFMessageComposeViewController  *messageVC = [[ MFMessageComposeViewController   alloc init ];
    
    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   whiteColor forKey : NSForegroundColorAttributeName ]];


这样的话,全局设置的 UINavigationBar   就不会影响  MFMessageComposeViewController   中的了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值