一个关于MFMessageComposeViewController的ios7中的诡异问题 收件人视图黑色 和解决方式
来源:互联网 发布:南通java培训费用 编辑:程序博客网 时间:2024/06/06 00:00
当使用
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 的界面, 短信收件人视图,竟然,先出现再消失,真是奇怪!!!
如果不加那句的话,显示就是正常的
搜索了下,看到网上也有人遇到了同样的问题
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://stackoverflow.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(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 中的了
1 0
- 一个关于MFMessageComposeViewController的ios7中的诡异问题 收件人视图黑色 和解决方式
- 一个关于MFMessageComposeViewController的ios7中的诡异问题 收件人视图黑色 和解决方式
- Struts2一个诡异问题的解决
- 一个诡异的问题,【已解决】
- python 一个诡异问题的解决
- 关于网页显示的一个诡异问题
- 关于索引的一个诡异问题
- 一个关于JavaScript的诡异问题
- Socket编程中的一个诡异的问题
- 一个诡异的问题
- 一个诡异的问题
- 一个诡异的问题
- 总算解决了QT的一个诡异问题
- 一个诡异的spark-submit运行问题(已解决)
- 关于分割视图中的一个小问题的解决方法
- 关于Java数组越界的一个诡异问题【leetcode204】
- 一个诡异的bash问题
- SqlParameter的一个诡异问题
- UITableView中确保UITableViewCellAccessoryCheckmark的唯一性
- Android开源项目第二篇——工具库篇
- HttpClient入门
- Axure 播放/暂停按钮的切换
- iOS Quartz: CGPathAddArc和CGPathAddArcToPoint函数
- 一个关于MFMessageComposeViewController的ios7中的诡异问题 收件人视图黑色 和解决方式
- android中利用webservice进行天气预报查询
- layoutSubviews总结
- but also entails pain and suffering
- struts框架实现的jsp页面的跳转的页面详细讲解---深入struts一下!
- vb6.0中提示:该部件的许可证信息没有找到,在设计环境中,没有合适的许可...
- hdu 2063 过山车(水题,二分图匹配)
- java任务计划
- 堆排序