【问题标题】:IOS erro at Posting to Facebook with the native Share dialog - UICGColor encodeWithCoderIOS 错误在使用本机共享对话框发布到 Facebook - UICGColor encodeWithCoder
【发布时间】:2012-11-15 18:33:31
【问题描述】:

错误:

-[UICGColor encodeWithCoder:] 中的断言失败, /SourceCache/UIKit/UIKit-2372/UIColor.m:1191 2012-11-15 14:17:45.531 Neemu Clothes[15179:4d07] 由于未捕获的异常而终止应用程序 '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:终止调用抛出异常

代码:

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, i.e. 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.");
    }

【问题讨论】:

  • 我该如何解决这个问题。
  • 你看过这个问题吗? stackoverflow.com/q/7456835/62662
  • 是的,看看这个问题,我的问题是 iOS 版 Facebook SDK。我无法解决这个问题。
  • 我遇到了同样的问题。如果您使用任何外观代理设置,似乎会发生这种情况。希望有解决方法?

标签: iphone ios facebook post sdk


【解决方案1】:

在我的委托中,我将 [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"background"]] 放入背景导航栏,我不知道为什么会发生这种崩溃,但是当我删除解决方案时 问题。

【讨论】:

    【解决方案2】:

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

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

    对于我来说,它是我的 AppDelegate 中 UIPageControl 上的 colorWithPatternImage。

    很多问题都是关于这个问题的。示例:UIApperance and various crashes 或者 iOS 6 MFMailComposeViewController: Only support RGBA or the White color space, this method is a hack

    【讨论】:

      【解决方案3】:

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

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

      像这样:

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

      【讨论】:

        【解决方案4】:

        我遇到了同样的问题,我通过子类化组件解决了这个问题。我的情况是:

        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 上发布。

        我认为,如果您的问题与我的类似,您可以尝试这种方法和您需要的子类组件(当然,如果它们打算被子类化)。

        最好的问候

        【讨论】:

          猜你喜欢
          • 2014-02-26
          • 1970-01-01
          • 2014-02-05
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-08-07
          相关资源
          最近更新 更多