我正在尝试编写一个函数,用户可以使用它将图片上传到我的服务器。但我不允许用户从照片卷中选择图片。有没有什么我可以用图像采集舱来做的?
func cancelButtonDidPress(imagePicker: ImagePickerController) {
imagePicker.dismissViewControllerAnimated(true, completion: nil)
}
func wrapperDidPress(imagePicker: ImagePickerController, images: [UIImage]) {
}
func doneButtonDidPress(imagePicker: ImagePickerController, images: [UIImage]) {
imagePicker.dismissViewControllerAnimated(true, completion: nil)
}
@IBAction func pictureButtonTapped(sender: AnyObject) {
//take picture
let imagePickerController = ImagePickerController()
imagePickerController.imageLimit = 1
imagePickerController.delegate = self
presentViewController(imagePickerController, animated: true, completion: nil)
}
最佳答案
您可以将sourceType
设置为camera
以仅作为相机打开图像选取器。
@IBAction func pictureButtonTapped(sender: AnyObject) {
let imagePickerController = ImagePickerController()
imagePickerController.imageLimit = 1
imagePickerController.delegate = self
// Add these lines
imagePickerController.sourceType = .camera
presentViewController(imagePickerController, animated: true, completion: nil)
}
关于ios - 仅使用通过相机,iOS/Swift拍摄的照片,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40215958/