を提示すると、次のクラッシュが発生しますMFMailComposeViewController
。
2013-11-08 11:04:05.963 <redacted>[7108:1603] *** Assertion failure in NSDictionary *_UIRecordArgumentOfInvocationAtIndex(NSInvocation *, NSUInteger, BOOL)(), /SourceCache/UIKit/UIKit-2380.17/UIAppearance.m:1118
2013-11-08 11:04:06.032 <redacted>[7108:1603] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unknown key, "NSColor" in title text attributes dictionary'
AppDelegate のapplication:didFinishLaunchingWithOptions:
メソッドで次の外観設定まで追跡しました。
[[UINavigationBar appearance] setTitleTextAttributes:
@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
その行をコメントアウトするとうまくいきますが、アプリの残りの部分が台無しになるため、titleTextAttributes を空の辞書に具体的に設定してみましたMFMailComposeViewController
。
試み #1
[[UINavigationBar appearanceWhenContainedIn:
NSClassFromString(@"MFMailComposeViewController"), nil]
setTitleTextAttributes:@{ }];
その結果、同じクラッシュが発生します。と
[[UINavigationBar appearanceWhenContainedIn:
NSClassFromString(@"MFMailComposeViewController"), nil]
setTitleTextAttributes:nil];
また、同じクラッシュが発生します。
試み #2
であることに気付いたMFMailComposeViewController
のでUINavigationController
、グローバルな外観設定が UINavigationController内の UIViewControllers にローカライズされている可能性があります。MFMailComposeViewController 内にあるビュー コントローラーを特定するコードをいくつかまとめました。
for (UIViewController *viewController in mailViewController.viewControllers) {
NSLog(@"%@", NSStringFromClass([viewController class]));
}
出力は次のようになります。
2013-11-08 11:04:05.936 <redacted>[7108:907] MFMailComposeInternalViewController
だから私は試しました(Appleのプライベートビューコントローラーに頼るのは悪い習慣ですが):
[[UINavigationBar appearanceWhenContainedIn:
NSClassFromString(@"MFMailComposeViewController"), nil]
setTitleTextAttributes:@{ }];
と
[[UINavigationBar appearanceWhenContainedIn:
NSClassFromString(@"MFMailComposeViewController"), nil]
setTitleTextAttributes:nil];
しかし、それでも同じクラッシュが発生します。
試み #3
// right before instantiating the MFMailComposeViewController
[[UINavigationBar appearance] setTitleTextAttributes:@{ }];
と
[[UINavigationBar appearance] setTitleTextAttributes:nil];
次に、の完了ブロックでグローバルな外観プロパティを復元しますdismissViewController:animated:completion:
しかし、この方法もうまくいきませんでした。UINavigationBar
MFMailComposeViewControllerをクラッシュさせずに、グローバルな外観にtitleTextAttributes を設定する方法を知っている人はいますか?