我正在使用cameraOverlayView创建自定义相机。但是,我不知道如何让按钮拍摄照片。 Apple Docs说takePicture()
是要使用的功能。但它没有编译:
两种尝试均无效:
let shootPicture = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, target: self, action: takePicture())
let shootPicture = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, target: self, { action -> Void in
takePicture()
})
let shootPicture = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, style: UIBarButtonItemStyle.Plain, target: self, action: "takePicture")
// separate function
func takePicture() {
imagePicker.takePicture()
}
仍然出现语法错误:missing argument for parameter 'landscapeImagePhone' in call
但是当我添加landscapeImagePhone: UIBarButtonSystemItem.Camera
时,我在调用中得到“额外参数'landscapeImagePhone'”
答案 0 :(得分:0)
对于其他坚持这一点的人:
let shootPicture = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, target: self, action: "takePicture")
func takePicture() {
imagePicker.takePicture()
}