Swift 使用cameraOverlayView拍摄照片()
我正在使用cameraOverlayView创建自定义摄影机。但是,我不知道如何让按钮拍摄照片。苹果公司的文档说,拍照是要使用的功能。但它没有编译: 这两种尝试都不起作用:Swift 使用cameraOverlayView拍摄照片(),swift,Swift,我正在使用cameraOverlayView创建自定义摄影机。但是,我不知道如何让按钮拍摄照片。苹果公司的文档说,拍照是要使用的功能。但它没有编译: 这两种尝试都不起作用: let shootPicture = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, target: self, action: takePicture()) let shootPicture = UIBarButtonItem(barB
let shootPicture = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, target: self, action: takePicture())
let shootPicture = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, target: self, { action -> Void in
takePicture()
})
更新的尝试:
仍在获取语法错误:调用中缺少参数“LandscapeMagePhone”的参数
但当我添加landscapeImagePhone:UIBarButtonSystemItem.Camera时,我在通话中得到了额外的参数“landscapeImagePhone”,供其他陷入此问题的人使用: 设置栏项目: 创建函数
let shootPicture = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, style: UIBarButtonItemStyle.Plain, target: self, action: "takePicture")
// separate function
func takePicture() {
imagePicker.takePicture()
}
let shootPicture = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, target: self, action: "takePicture")
func takePicture() {
imagePicker.takePicture()
}