I am trying to allow the user to edit an existing photo using the move and scale view and allow them to edit any picture they pick or take but I can't get the move and scale view to appear correctly. How do I get the title and circle view to show? This is what it looks like now:
and this is what I want:
func addImage(sender: UIButton) {
self.view.endEditing(true)
let alert = UIAlertController(title: "", message: nil, preferredStyle: .actionSheet)
var numberAlert = UIAlertAction(title: "Take Photo", style: UIAlertActionStyle.default, handler: { action in
self.takePhoto()
})
alert.addAction(numberAlert)
numberAlert = UIAlertAction(title: "Choose Photo", style: UIAlertActionStyle.default, handler: { action in
self.choosePhoto()
})
alert.addAction(numberAlert)
numberAlert = UIAlertAction(title: "Edit Photo", style: UIAlertActionStyle.default, handler: { action in
self.editPhoto()
})
alert.addAction(numberAlert)
numberAlert = UIAlertAction(title: "Delete Photo", style: UIAlertActionStyle.default, handler: { action in
self.deletePhoto()
})
alert.addAction(numberAlert)
let cancelAlert = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.default, handler:nil)
cancelAlert.setValue(UIColor.blue, forKey: "titleTextColor")
alert.addAction(cancelAlert)
self.present(alert, animated: true, completion: nil)
}
func choosePhoto() {
imagePicker = nil
imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.allowsEditing = true
imagePicker.sourceType = .photoLibrary
present(imagePicker, animated: true, completion: nil)
}
func takePhoto() {
imagePicker = nil
imagePicker = UIImagePickerController()
imagePicker.resignFirstResponder()
imagePicker.delegate = self
imagePicker.allowsEditing = true
imagePicker.sourceType = .camera
present(imagePicker, animated: true, completion: nil)
}
func editPhoto() {
}
func deletePhoto() {
}
//MARK: - Saving Image here
@IBAction func save(_ sender: AnyObject) {
UIImageWriteToSavedPhotosAlbum(self.contact.image!, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
}
//MARK: - Add image to Library
func image(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
if let error = error {
NSLog("Error saving image: \(error)")
} else {
self.tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: UITableViewRowAnimation.none)
}
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
imagePicker.dismiss(animated: true, completion: nil)
self.contact.image = info[UIImagePickerControllerOriginalImage] as? UIImage
self.tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: UITableViewRowAnimation.none)
}