我正在我的应用程序中实现自动增强功能.我的代码是这样的:
CIImage *toBeEnhancedImage = [CIImage imageWithCGImage:_originalImage.CGImage];
NSDictionary *options = @{CIDetectorImageOrientation : [[toBeEnhancedImage properties] valueForKey:kCGImagePropertyOrientation]};
NSArray *adjustments = [toBeEnhancedImage autoAdjustmentFiltersWithOptions:options];
Run Code Online (Sandbox Code Playgroud)
在运行代码之前,我在NSDictionary旁边收到以下错误:
不兼容的指针类型将'const CFStringRef(AKA'const struct__CFString const)发送到NSString类型的参数*
当我运行代码时,它崩溃了.我知道错误意味着什么,但代码实际上来自Apple的文档,它不起作用!有解决方法吗?
你应该输入你的CFStringRef变量NSString *.使用以下行更改代码的第二行:
NSDictionary *options = nil;
if([[toBeEnhancedImage properties] valueForKey:(NSString *)kCGImagePropertyOrientation] == nil)
{
options = @{CIDetectorImageOrientation : [NSNumber numberWithInt:1]};
}
else
{
options = @{CIDetectorImageOrientation : [[toBeEnhancedImage properties] valueForKey:(NSString *)kCGImagePropertyOrientation]};
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1917 次 |
| 最近记录: |