reason: 'Unknown key, "NSColor" in title text attributes dictionary
2014-07-18 10:54
555 查看
iOS 6 和 iOS 7 兼容性问题,在调用内部发短信接口时候,出现了异常崩溃,原来一直在iOS7 下测试,一切正常,但是在iOS 6下却突然崩溃,具体代码如下:
注意:中间有一段是设置短信导航标题的代码,然后爆出如下异常:
解决方案如下即可:
1,删除这段修改短信标题的代码,似乎不起作用,汗..
2,版本判断 #define OS_VERSION [[UIDevice currentDevice].systemVersion floatValue]
即可适配 iOS6 和 iOS 7 发送短信功能。
个人开发者梦工厂之 微推:www.micropush.cn
- (void)showMessageViewWithRecipients:(NSArray *)recipients body:(NSString *)bodyMess { if( [MFMessageComposeViewController canSendText] ){ <span style="font-family: Arial, Helvetica, sans-serif;"> [[UINavigationBar appearance] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];</span>
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor darkGrayColor],NSForegroundColorAttributeName, [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil]]; MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init]; controller.recipients = recipients; controller.body = bodyMess; controller.messageComposeDelegate = self; [self presentViewController:controller animated:NO completion:nil]; }else{ [self alertWithTitle:@"提示信息" msg:@"设备没有短信功能"]; } }
注意:中间有一段是设置短信导航标题的代码,然后爆出如下异常:
[code]Assertion failure in NSDictionary *_UIRecordArgumentOfInvocationAtIndex(NSInvocation *, NSUInteger, BOOL)(), /SourceCache/UIKit/UIKit-2380.17/UIAppearance.m:1118 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unknown key, "NSColor" in title text attributes dictionary'
解决方案如下即可:
1,删除这段修改短信标题的代码,似乎不起作用,汗..
2,版本判断 #define OS_VERSION [[UIDevice currentDevice].systemVersion floatValue]
- (void)showMessageViewWithRecipients:(NSArray *)recipients body:(NSString *)bodyMess { if( [MFMessageComposeViewController canSendText] ){ if (OS_VERSION>=7.0) { [[UINavigationBar appearance] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor darkGrayColor],NSForegroundColorAttributeName,[UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil]]; } MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init]; controller.recipients = recipients; controller.body = bodyMess; controller.messageComposeDelegate = self; [self presentViewController:controller animated:NO completion:nil]; }else{ [self alertWithTitle:@"提示信息" msg:@"设备没有短信功能"]; } }
即可适配 iOS6 和 iOS 7 发送短信功能。
个人开发者梦工厂之 微推:www.micropush.cn
相关文章推荐
- "NSInternalInconsistencyException', reason: 'This NSPersistentStoreCoordinator has no persistent sto
- reason: 'Could not load NIB in bundle: "XXXXXXX" with name 'xxCell'
- "The file you are trying to open, '[filename]', is in a different format" Excel Error
- A question posted in xbrl-dev, about consistency-assertion's @decimlas = "INF"
- Writing endian-independent code in C(Don't let endianness "byte" you)
- hive -e "show tables"提示cannot recognize input near 'show' '<EOF>' '<EOF>' in ddl statement
- 在JS里面,取struts的<html:form>标签里面的<html:text property="title"/>值
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'e.title' in
- Imagemagick + vs2008 的error C3163: '_vsnprintf': attributes inconsistent with previous declaration 编译错误
- python 处理中文时出现的错误'ascii' codec can't decode byte 0xe9 in position 0: ordinal not in range(128)" 解决方法
- Error:'Please set up the forwarding function parameter "wipnp" in the workstation startup function!'
- Search all jsp filename in the text,but the filename which should not include the symbol '_'
- *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not
- ADODB使用excel的"Cannot modify the design of table 'xxxx'. It is in a read-only database"的问题
- What's "new" in JavaScript?
- "An extender can't be in a different UpdatePanel than the control it extends." error really needs debugging information ,错误
- How "Copy File" works in 'View Output" screen in Oracle Apps
- EXEC master..xp_cmdshell 'bcp inzool.dbo.Out_Dv_Topic out c:/temp1.xls -c -q -S"127.0.0.1" -U"sa" -P"111111"'
- 'System.Threading.ThreadStateException' occurred in "System.Windows.Forms.dll " in opencv1.1 version
- 关于C#中的错误:The type 'X' does not exists in the "Y"