【发布时间】:2016-02-22 19:45:21
【问题描述】:
我的新界面需要调用旧的(Objective-C)渲染函数。首先我尝试了这个:
func renderImage(image:UIImage) {
var imageCopy = UIImage(CGImage: image.CGImage!)
Renderer.imageWithSourceImg(&imageCopy, ...)
}
我得到一个错误:
'&' used with non-inout argument of type 'AutoreleasingUnsafeMutablePointer<UIImage?>'
我已经阅读了有关如何使用指针调用函数的信息,您需要使用var 绑定而不是let,这就是我猜测imageCopy 的原因。
基本上,我有一个作为参数传入的不可变图像,我需要调用一个将可变图像指针作为参数的函数。怎么样?
更新:Objective-c 接口:
+(UIImage *)imageWithSourceImg:(UIImage **)_sourceImgPtr
...
【问题讨论】:
-
请注意,我也尝试过创建一个全新的不相关图像。我也无法让它工作。
-
请展示Objective-C API。如果我们不知道 Objective-C 是如何声明函数的,就无法告诉你如何调用 Objective-C 函数。
-
尝试让变量 'imageCopy' 的类型为 'UIImage?'。
标签: ios objective-c swift pointers uiimage