UIImagePickerController在Swift 3中的图像编辑模式下更改底栏按钮标题

时间:2017-01-24 15:04:23

标签: ios swift uiimagepickercontroller

enter image description here

  

我想在更改期间更改UIImagePickerController底栏按钮   swift 3中的图像编辑模式,Xcode 8.2.1。   目前按钮的显示方式与我在图片中提到的一样。

class MyController:UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

    @IBOutlet weak var imageV: RoundedImageView!

    let imagePicker = UIImagePickerController()

    override func viewDidLoad() {
        super.viewDidLoad()

        self.imagePicker.delegate = self
    }

    //MARK:- Action
    @IBAction func libraryButtonPressed(_ sender: Any) {
        self.imagePicker.allowsEditing = true
        self.imagePicker.sourceType = .photoLibrary
        self.present(self.imagePicker, animated: true, completion: nil)
    }

    @IBAction func cameraButtonPressed(_ sender: Any) {
        self.imagePicker.allowsEditing = true
        self.imagePicker.sourceType = .camera
        self.present(self.imagePicker, animated: true, completion: nil)
    }

    // MARK: - UIImagePickerControllerDelegate Methods

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

        if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
            self.imageV.contentMode = .scaleAspectFit
            self.imageV.image = pickedImage
        }

        self.dismiss(animated: true, completion: nil)
    }

    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        self.dismiss(animated: true, completion: nil)
    }
}
  

请建议我..

1 个答案:

答案 0 :(得分:1)

确保您未在​​应用程序中使用本地化,如果您正在使用本地化,请正确配置所有字符串文件。

看看这个解决方案: https://stackoverflow.com/a/42008789/2898708

我添加了 PhotoLibrary.strings ,并在其中添加了以下字符串

"CANCEL" = "Cancel";
/* Title of button to set contact photo */
"SET_PHOTO_BUTTON" = "Set Photo";

"CHOOSE_PHOTO_BUTTON" = "Choose";

"USE_PHOTO_BUTTON" = "Use Photo";