1

以下行在 iPad 上崩溃。我正在使用带有 6.0 的 Xcode 4.6.3 (4H1503) 作为目标操作系统平台。它曾经工作得很好!

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] *由于未捕获的异常“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]`;
4

1 回答 1

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]};
于 2013-09-16T17:16:32.140 回答