不确定我做错了什么。我正在使用此模块https://github.com/wenzhaot/InstagramPhotoPicker(块的头文件在这里https://github.com/wenzhaot/InstagramPhotoPicker/blob/master/TWPhotoPicker/TWPhotoPickerController.h)
在Objective-C中,语法为:
photoPicker.cropBlock = ^(UIImage *image) {
//do something
};
我尝试将其转换为swift,但我收到错误
photoPicker.cropBlock{ (image:UIImage) -> () in
//Do something
//error: cannot invoke 'cropBlock' with an argument list of type '((UIImage) -> ())'
}
如何让它发挥作用?
答案 0 :(得分:2)
您只是缺少=
标志。另外image
是隐式解包的可选:
photoPicker.cropBlock = { (image: UIImage!) -> () in
//Do something
}
或
photoPicker.cropBlock = { image in
//Do something
}