使用UIAppearance代理自定义字体时,MFMailComposeViewController不起作用

时间:2013-03-08 09:29:50

标签: iphone ios mfmailcomposeviewcontroller uiappearance

当我不在我的应用程序中自定义字体时,MFMailComposeViewController会显示并正常工作。但是当我这样做的时候,有50%的时间会被呈现,并直接用mailComposeController:didFinishWithResult:MFMailComposeResultCancelled的代表联系,结果为_serviceViewControllerReady:error: Error Domain=XPCObjectsErrorDomain Code=2 "The operation couldn’t be completed. (XPCObjectsErrorDomain error 2.)" ,就像用户只是试图关闭它一样。

并在控制台中触发此错误:

UIImage *navBarBackground = [UIImage stretchableHorizontalImageNamed:@"navbar-background"];
[[UINavigationBar appearance] setBackgroundImage:navBarBackground forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[UIImage imageNamed:@"navbar-shadow"]];
[[UINavigationBar appearance] setTitleTextAttributes:@{
    UITextAttributeTextColor: [UIColor colorWithRed:0.965f green:0.635f blue:0.647f alpha:1.f],
    UITextAttributeFont : [UIFont brothersBoldFontOfSize:20.f],
    UITextAttributeTextShadowColor: [UIColor blackColor],
    UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, -1)]
}];

UIBarButtonItem *navBarButtonItemAppearance = [UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil];
[navBarButtonItemAppearance setTitleTextAttributes:@{
    UITextAttributeTextColor: [UIColor colorWithRed:0.478f green:0.008f blue:0.023f alpha:1.f],
    UITextAttributeFont : [UIFont brothersBoldFontOfSize:17.f],
    UITextAttributeTextShadowColor: [UIColor colorWithWhite:1.f alpha:0.3f],
    UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, 1)]
} forState:UIControlStateNormal];

看起来邮件编辑器不喜欢外观代理,但问题是它不是事件可能会禁用它的外观代理。

对于我的应用程序中的每个导航栏,我都有自定义设计。为实现这一点,我使用了外观代理:

[[UINavigationBar appearanceWhenContainedIn:[UIPopoverController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];

我删除了popover的一些后台自定义:

nil

它适用于popover。但是不可能为邮件编写器删除它,即使我使用“包含在”MFMailComposeViewController中并将其设置为{{1}}它仍然在这里。

我也尝试将其子类化或设置系统字体,但这不会改变任何东西。他出现了,打印错误,打电话给他的代表并被解雇。我刚刚看到它在工作时,系统不会应用该字体,当它没有显示时,它会显示如下的自定义字体。

enter image description here

1 个答案:

答案 0 :(得分:2)

问题是自定义字体加载时间太长,并且会触发等待时间超时。

请参阅:MFMailComposeViewController throws a viewServiceDidTerminateWithError and then exits when using a custom title font