'- [CIContext initWithOptions:]: unrecognized selector sent to the instance

I used this to create a large image:

let context = CIContext(options: nil)
let bitmapImage: CGImageRef = context.createCGImage(image, fromRect: extent)!
CGContextSetInterpolationQuality(bitmapRef,  CGInterpolationQuality.None)
CGContextScaleCTM(bitmapRef, scale, scale);
CGContextDrawImage(bitmapRef, extent, bitmapImage);
let scaledImage: CGImageRef = CGBitmapContextCreateImage(bitmapRef)!
return UIImage(CGImage: scaledImage)

It worked fine in iOS 9 and 10, but not in 8. I got this in the debugger:

Application termination due to an uncaught exception 'NSInvalidArgumentException', reason: '- [CIContext initWithOptions:]: unrecognized selector sent to instance 0x7f868d5dc8e0'

Besides. Instead, I tried to use let context = CIContext(). But in the second line, I got zero. I am using Xcode 8 and Swift 2.3. Please help me with this! Thank!

+4
source share
1 answer

, , : Objective-C. :

ContextMaker.h

#import <Foundation/Foundation.h>
#import <CoreImage/CoreImage.h>

@interface ContextMaker : NSObject

+ (CIContext*) makeMeAContext;

@end

ContextMaker.m

#import "ContextMaker.h"

@implementation ContextMaker

+ (CIContext*) makeMeAContext {
    return [CIContext contextWithOptions:nil];
}

@end

:

#import "ContextMaker.h"

Swift:

let c = ContextMaker.makeMeAContext()

, , , ...

+9

Source: https://habr.com/ru/post/1657163/


All Articles