我正在使用cameraOverlayView创建一个自定义摄像头。然而,我不确定如何让按钮拍摄照片。苹果公司的文件说,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
但是当我添加调用时,我得到"extra argument 'landscapeImagePhone‘in landscapeImagePhone: UIBarButtonSystemItem.Camera“
发布于 2015-03-21 04:21:01
对于其他坚持这一点的人:
设置条形项:
let shootPicture = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, target: self, action: "takePicture")创建函数
func takePicture() {
imagePicker.takePicture()
}https://stackoverflow.com/questions/29174006
复制相似问题