【问题标题】:Why do I get 'No -renderInContext: method found' warning?为什么我会收到“No -renderInContext: method found”警告?
【发布时间】:2011-06-13 19:43:02
【问题描述】:

我在 -renderInContext 处收到编译器警告:

- (UIImage *) imageFromView:(UIView *)view {
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();    
    UIGraphicsEndImageContext();
    return img; 
}

我在项目框架中有 QuartzCore,并且代码有效。 如何修复代码以使其不再向我发出警告?

我得到的确切警告是

warning: no '-renderInContext:' method found
warning: (Messages without a matching method signature
warning: will be assumed to return 'id' and accept
warning: '...' as arguments.)

【问题讨论】:

    标签: iphone ios


    【解决方案1】:

    尝试将 Quartz 框架导入您的应用程序。

    然后添加,

    #include <QuartzCore/QuartzCore.h>

    到您的应用程序。

    【讨论】:

    • @Altaveron,你能详细说明一下吗?如果您有具体问题,我建议您打开一个单独的 SO 问题。
    【解决方案2】:

    你的项目中有 QuartzCore.framework 吗?

    【讨论】:

      【解决方案3】:

      我想这是因为 CALayer 类头在 QuartzCore 框架中。

      在 Xcode 的 Frameworks 组中,添加 QuartzCore 框架,应该没问题。

      然后,请参阅my post here on SO,了解如何在每个源文件中包含头文件。现在它不是用于 Core Data,而是用于 QuartzCore(以完全相同的方式)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-10
        • 2012-08-10
        • 2019-05-06
        相关资源
        最近更新 更多