奇怪的 MFMailComposeViewController 崩溃 [英] Weird MFMailComposeViewController Crash
问题描述
以下几行在 iPad 上崩溃了.我使用 Xcode 4.6.3 (4H1503) 和 6.0 作为目标操作系统平台.它曾经工作得很好!
Following lines are crashing on iPad. I am using Xcode 4.6.3 (4H1503) with 6.0 as target OS platform. It used to work just fine!
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
[self presentViewController:mailViewController animated:YES completion:nil];
}
以下情况除外:
2013-09-04 02:30:47.489 MyProject[38633:5b0b] * 断言失败NSDictionary *_UIRecordArgumentOfInvocationAtIndex(NSInvocation *,NSUInteger, BOOL)(),/SourceCache/UIKit_Sim/UIKit-2380.17/UIAppearance.m:1118
2013-09-04 02:30:47.489 MyProject[38633:5b0b] * Assertion failure in NSDictionary *_UIRecordArgumentOfInvocationAtIndex(NSInvocation *, NSUInteger, BOOL)(), /SourceCache/UIKit_Sim/UIKit-2380.17/UIAppearance.m:1118
2013-09-04 02:31:00.816 MyProject[38633:5b0b] * 终止应用到期未捕获的异常NSInternalInconsistencyException",原因:'未知键,{大小= 13.000000,特征=00000000}" 在标题文本属性字典中'
2013-09-04 02:31:00.816 MyProject[38633:5b0b] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unknown key, "{size = 13.000000, traits = 00000000}" in title text attributes dictionary'
由于以下几行而崩溃.猜猜为什么?从未想过 MFMailComposeViewController
可能与 UITabBarItem
有任何关系...
Its crashing due to the following lines. Any guess why? Never thought MFMailComposeViewController
could have any relation to UITabBarItem
...
NSDictionary *textAttributesDict = @{ [UIColor whiteColor] : UITextAttributeTextColor,
[UIFont systemFontOfSize:13.0f] : UITextAttributeFont};
[[UITabBarItem appearance] setTitleTextAttributes:textAttributesDict forState:UIControlStateSelected];
[[UITabBarItem appearance] setTitleTextAttributes:textAttributesDict forState:UIControlStateNormal]`;
推荐答案
NSDictionary
的键/值颠倒了.它应该有 key:value 而不是 value:key
The NSDictionary
had key/value reversed. It is supposed to have key:value instead of value:key
NSDictionary *textAttributesDict = @{ [UIColor whiteColor] : UITextAttributeTextColor,
[UIFont systemFontOfSize:13.0f] : UITextAttributeFont};
将以上更改为以下有效.感谢 Desdenova 指点.
Changing above to the following worked. Thanks Desdenova for a pointer.
NSDictionary *textAttributesDict = @{UITextAttributeTextColor : [UIColor whiteColor],
UITextAttributeFont : [UIFont systemFontOfSize:13.0f]};
这篇关于奇怪的 MFMailComposeViewController 崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!