IOS错误在使用本机共享对话框发布到Facebook – UICGColor encodeWithCoder

埃罗:

断言失败 – [UICGColor encodeWithCoder:],/ SourceCache / UIKit / UIKit-2372 / UIColor.m:1191 2012-11-15 14:17:45.531 Neemu Clothes [15179:4d07]由于未捕获的exception’NSInternalInconsistencyException’而终止应用程序,原因:“只支持RGBA或白色空间,这种方法是黑客攻击。” *第一掷调用堆栈:(0x363272a3 0x32afe97f 0x3632715d 0x37a492af 0x36c793c5 0x379ec00f 0x379eb8b5 0x36dac72d 0x36daba7b 0x3632462f 0x36dab7f5 0x36e895e5 0x36e17cd7 0x36e17b6d 0x3506890f 0x36e17a61 0x36e210d5 0x3505b83b 0x36e210b1 0x3505b11f 0x3505a99b 0x3505a895 0x35069215 0x350693b9 0x357f8a11 0x357f88a4)的libc ++ abi.dylib:终止叫做抛出一个exception

码:

BOOL displayedNativeDialog = [FBNativeDialogs presentShareDialogModallyFrom:self initialText:@"NeeemuG - Veja meu look." image:nil url:[NSURL URLWithString:@"https://www.neemu.com"] handler:^(FBNativeDialogResult result, NSError *error) { // Only show the error if it is not due to the dialog // not being supporte, ie code = 7, otherwise ignore // because our fallback will show the share view controller. if (error && [error code] == 7) { return; } NSString *alertText = @""; if (error) { alertText = [NSString stringWithFormat: @"error: domain = %@, code = %d", error.domain, error.code]; } else if (result == FBNativeDialogResultSucceeded) { alertText = @"Posted successfully."; } if (![alertText isEqualToString:@""]) { // Show the result in an alert [[[UIAlertView alloc] initWithTitle:@"Result" message:alertText delegate:self cancelButtonTitle:@"OK!" otherButtonTitles:nil] show]; } }]; // Fallback, show the view controller that will post using me/feed if (!displayedNativeDialog) { NSLog(@"No IOS6."); } 

在我的委托我把[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@“background”]]放到后台导航栏,我不知道为什么会崩溃,但当我删除解决问题。

我有同样的问题,它似乎(显然)与方法[UIColor colorWithPatternImage:image]相关联;

因此,我建议检查调用colorWithPatternImage的每个方法,并逐个注释调用该方法的每一行以找出源。

对于我的情况,它是我的AppDelegate中UIPageControl上的colorWithPatternImage。

关于这个问题很多问题。 示例: UIApperance和各种崩溃或iOS 6 MFMailComposeViewController:仅支持RGBA或白色空间,此方法是黑客

我有同样的问题,我通过子类化组件修复了这个问题。 我的情况是:

 UIColor *bkg = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bkg"]]; [[UICollectionView appearance] setBackgroundColor:bkg]; 

当我试图在Facebook上发布一些东西我收到错误,但后来我创建了UICollectionView简单子类 – 让我们将其命名为MyGridView 。 所以修改后我的代码是:

 UIColor *bkg = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bkg"]]; [[MyGridView appearance] setBackgroundColor:bkg]; 

然后我在故事板中更改了视图以使用自定义组件类MyGridView而不是默认的UICollectionView ,一切正常 – 我有想要的背景,并且能够在Facebook上发布。

我认为如果你的问题与我的问题类似,你可以尝试这种方法和你需要的子类组件(如果它们当然是用于子类)。

最好的祝福

对我来说,这个错误是由UITextField和UISwitch上的外观设置引起的。

我有一个抽象的视图控制器子类,我的所有视图控制器都inheritance自,所以我只是指定只在我的视图中设置从该视图控制器inheritance的外观。

像这样:

 [[UITextField appearanceWhenContainedIn:[BaseViewController class], nil] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bkg"]]]; [[UISwitch appearanceWhenContainedIn:[BaseViewController class], nil] setOnTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bkg"]]];