我正在使用Canhub Cropper库来裁剪我的android项目中的图像。然而,我在执行中发现了一个奇怪的问题。首先,下面是启动cropper的代码:
import com.canhub.cropper.CropImageView
import com.canhub.cropper.CropImageContract
private var croplauncher = registerForActivityResult(CropImageContract()) { result ->
if (result.isSuccessful) {
// Use the returned uri.
val uriContent = result.uriContent
val uriFilePath = result.getUriFilePath(this@Doctor) // optional usage
//Do More Here
} else {
// An error occurred.
val exception = result.error
}
}
private fun cropImage() {
croplauncher.launch(
options {
setGuidelines(CropImageView.Guidelines.ON)
}
)
}
在这段代码中,android studio抛出了一个错误:Unresolved Reference: options in cropImage函数
坚持了很长时间。如有任何帮助,不胜感激
我认为这是一个缺失的功能,或者只是库文档过时了。但是你可以像这样改变cropImage
private fun cropImage() {
// Start picker to get image for cropping and then use the image in cropping activity.
cropImage.launch(
CropImageContractOptions(uri = "YOUR URI", cropImageOptions = CropImageOptions(
guidelines = CropImageView.Guidelines.ON
))
)
}