奇怪的MFMailComposeViewController崩溃

时间:2013-09-04 07:39:49

标签: objective-c uikit

以下线路在iPad上崩溃。我使用Xcode 4.6.3(4H1503)和6.0作为目标OS平台。过去工作得很好!

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:31:00.816 MyProject [38633:5b0b] * 终止app到期   未捕获的异常'NSInternalInconsistencyException',原因:   '未知密钥,“{size = 13.000000,traits =   00000000}“在标题文本属性字典'

编辑:由于以下行而崩溃。有什么猜?从未想过MFMailComposeViewController可能与UITabBarItem ...

有任何关系
NSDictionary *textAttributesDict = @{ [UIColor whiteColor] : UITextAttributeTextColor,
                                          [UIFont systemFontOfSize:13.0f] : UITextAttributeFont};

[[UITabBarItem appearance] setTitleTextAttributes:textAttributesDict forState:UIControlStateSelected];
[[UITabBarItem appearance] setTitleTextAttributes:textAttributesDict forState:UIControlStateNormal]`;

1 个答案:

答案 0 :(得分:1)

NSDictionary的键/值已反转。它应该有 key:value 而不是 value:key

NSDictionary *textAttributesDict = @{ [UIColor whiteColor] : UITextAttributeTextColor,
                                          [UIFont systemFontOfSize:13.0f] : UITextAttributeFont};

将以上内容更改为以下内容。谢谢Desdenova的指针。

NSDictionary *textAttributesDict = @{UITextAttributeTextColor : [UIColor whiteColor],
                                          UITextAttributeFont : [UIFont systemFontOfSize:13.0f]};