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

问题描述:

当我未自定义我的应用程序中的字体时,MFMailComposeViewController显示并工作正常。但是当我这样做的时候,有50%的时间出现,并直接打电话给他的代表mailComposeController:didFinishWithResult:,结果MFMailComposeResultCancelled就好像用户试图关闭它一样。当使用UIAppearance代理自定义字体时,MFMailComposeViewController不起作用

而且还会引发这个错误在控制台:

_serviceViewControllerReady:error: Error Domain=XPCObjectsErrorDomain Code=2 "The operation couldn’t be completed. (XPCObjectsErrorDomain error 2.)" 

貌似邮件作曲家不喜欢外观代理,但问题是,它不是事件可能去禁用外观代理吧。

对于我的应用程序中的每个导航栏,我都有一个自定义设计。要做到这一点我用这样的appearence代理:

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]; 

它的正常工作为酥料饼。但是,即使当我使用“当包含在”MFMailComposeViewController并将其设置为nil时,它仍然存在,但不可能为邮件编辑器删除它。

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

enter image description here

+0

嘿,你有解决方案吗?因为我面临同样的问题,并且在几天之后也一起搜索。如果你已经成功解决了这个问题,请让我知道...... :) – Krunal 2013-03-30 06:48:54

+0

还没有解决方案。 – 2013-03-30 20:50:39

+1

我已经得到了解决方案....如果你已经在你的任何类中用'UINavigationBar'设置了自定义字体,那么它会影响'MFMailComposeViewController'。所以,你从所有的类中删除自定义的导航栏字体,它会正常工作。我认为这是唯一的解决方案。你可能已经设置导航栏自定义字体... :) – Krunal 2013-04-01 05:55:24

的问题是,自定义字体花费太长的时间来加载,并触发从等待围栏超时。

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

+1

我也看到了这个链接,但没有解决方案。解决方法代码不起作用(在iOS 6上)。 – 2013-03-12 16:43:12