- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在自定义我的应用程序时感到非常沮丧。我已经创建并设置了几乎整个应用程序的样式,包括导航栏、工具栏、tabBar 等,但每次 MFMailComposeViewController、MFMessageComposerViewController、Twitter 或 Facebook 共享器甚至 QuickLook View Controller 出现时,应用程序都会崩溃并显示以下消息:
*** Assertion failure in -[UICGColor encodeWithCoder:].
*** Terminating app due to uncaught exception 'NSInternalInconsistencyExceptionì, reason: 'Only RGBA or White color spaces are supported in this situation.'
我听说这是因为 iOS 6 将 Composer 作为远程 Controller 进行管理,但我真的不知道如何解决这个问题。
我不想因此删除邮件撰写功能或消息撰写功能。
有人遇到过这个错误吗?
我已经写好了代码。问题是 UIAppearance 由于自定义 UINavigationBars 元素而导致应用程序崩溃。代码。
-(void)message{
if (_progressHUD){
[_progressHUD hide:YES];
}
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init] ;
[controller setMessageComposeDelegate:self];
if([MFMessageComposeViewController canSendText])
{
controller.body = descriptionString;
controller.recipients = nil;
[self presentViewController:controller animated:YES completion:nil];
}
}
-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void)email {
if (_progressHUD){
[_progressHUD hide:YES];
}
MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
[composer setMailComposeDelegate:self];
if ([MFMailComposeViewController canSendMail]) {
[composer setToRecipients:nil];
[composer setSubject:[NSString stringWithFormat:@"%@",nameString]];
[composer setMessageBody:[NSString stringWithFormat:@"%@",descriptionString] isHTML:NO]; [composer addAttachmentData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageString]] mimeType:@"png" fileName:imageString];
[composer setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:composer animated:YES completion:nil];
}
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
if (error) {
SIAlertView *alert = [[SIAlertView alloc] initWithTitle:@"Error"
andMessage:[NSString stringWithFormat:@"Error %@", [error description]]];
[alert addButtonWithTitle:@"OK" type:SIAlertViewButtonTypeDestructive handler:^(SIAlertView *alertView){}];
[alert show];
[self dismissViewControllerAnimated:YES completion:nil];
}
else {
[self dismissViewControllerAnimated:YES completion:nil];
}
}
外观
- (void)customizeAppearance
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
UINavigationBar Appearance
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigationBarBackground"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],
UITextAttributeTextColor,
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0],
UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"HelveticaNeue" size:0.0],
UITextAttributeFont,
nil]];
//ToolBar Appearance
[[UIToolbar appearance] setTintColor:[UIColor whiteColor]];
//Switch Appearance
[[UISwitch appearance] setOnTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"greenBackground"]]];
//Search Bar Appearance
[[UISearchBar appearance] setTintColor:[UIColor whiteColor]];
//Tab Bar Appearance
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabBarBackground"]];
[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], UITextAttributeTextColor, nil] forState:UIControlStateNormal];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"transparent"]];
}
最佳答案
经过各种调试 session 后,我整理出导致这些崩溃的代码行是
//Switch Appearance
[[UISwitch appearance] setOnTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"greenBackground"]]];
所以我删除了它,一切正常。显然,我不能直接在 AppDelegate 中设置外观,但我必须在开关所在的类中进行设置。
对于 refreshControl 外观也是如此:必须在 tableView 的类中设置它。
关于ios - UIApperance 和各种崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18570766/
我在自定义我的应用程序时感到非常沮丧。我已经创建并设置了几乎整个应用程序的样式,包括导航栏、工具栏、tabBar 等,但每次 MFMailComposeViewController、MFMessage
我正在尝试弄清楚如何在 Xamarin 中实现以下代码: [[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setDe
我正在使用主题概念来更改我的应用程序中的 UI 外观。我正在使用多个主题。我想更改每个 View Controller 的导航栏的颜色,但 除外注册 View Controller .那么我该怎么做呢
我最近尝试向我的一个 Swift 类 (ScoreView) 添加符合 UIApperance 的属性,但没有成功。您可以在下面看到相关代码: private var gaugeThresholds
我正在尝试使用外观来设置整个应用程序的常规默认布局/设计。对于 UISwitch,要不仅在边框处设置 off 颜色,还必须进行调整(请参阅 Change color of UISwitch in "o
我是一名优秀的程序员,十分优秀!