UIImage *img = [UIImage imageNamed:@"navigation-bar-bg"];//
navi_stretch_bg
img = [img resizableImageWithCapInsets:UIEdgeInsetsMake(2, 1, 2, 0)];
[[UINavigationBar appearance] setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
img = [img resizableImageWithCapInsets:UIEdgeInsetsMake(2, 1, 2, 0)];
[[UINavigationBar appearance] setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
后,
弹出的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 的行为,至于苹果为什么这么做,实在是弄不懂
解决方式
本来我们设置
UIImage *img = [UIImage imageNamed:@"navigation-bar-bg"];//
navi_stretch_bg
img = [img resizableImageWithCapInsets:UIEdgeInsetsMake(2, 1, 2, 0)];
[[UINavigationBar appearance] setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
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
@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];
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];
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]];
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
中的了
一个关于MFMessageComposeViewController的ios7中的诡异问题 收件人视图黑色 和解决方式,布布扣,bubuko.com