当用户将.Camera选项用于UIImagePicker时,按钮上用于确认图片的默认文本为“使用图片”。

有什么办法可以将其更改为其他字符串吗?

最佳答案

func chooseAlert(){


        let alert = UIAlertController(title: "Upload Image", message: "Choose Source For Image.", preferredStyle: .ActionSheet)

        let cameraAction = UIAlertAction(title: "Take Photo", style: .Default, handler: { (action:UIAlertAction) -> Void in

                    dispatch_async(dispatch_get_main_queue())
            {
//                self.performSelector(#selector(self.useCamera), withObject: nil, afterDelay: 1.0)
                self.useCamera()
            }
        })

        let cameraRollAction = UIAlertAction(title: "Use Photo", style: .Default, handler: { (action:UIAlertAction) -> Void in

            dispatch_async(dispatch_get_main_queue())
            {
                self.useCameraRoll()
            }
        })

        let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel){
            (action) in
            print(action)
        }

        alert.addAction(cameraAction)
        alert.addAction(cameraRollAction)
        alert.addAction(cancelAction)
        presentViewController(alert, animated: true, completion: nil)

   }


在按钮的IBAction中,调用此函数,它将在屏幕上显示警报。在警报操作中,根据需要更改标题。 useCamera()和useCameraRoll()是用户定义的函数。

10-07 21:53