我正在尝试从相机或图库中选择图像,然后在图像视图中将所选图像显示在屏幕上。但是它没有显示。
public void saveImage(Bitmap bitmap) {
String filename = "dy/dx_wallpaper-" + System.currentTimeMillis();
String url = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, filename, "Gradient Wallpaper");
Toast.makeText(MainActivity.this, "Saved as " + url, Toast.LENGTH_SHORT).show();
}
我想念什么?
就我而言,断点功能根本没有调用
答案 0 :(得分:1)
我之前也遇到过同样的问题,并通过设置图像延迟来解决它,如下所示:
e.preventDefault()
希望这会有所帮助。
答案 1 :(得分:1)
确保已将UIImagePickerControllerDelegate
添加到课程中,并设置了UIImagePickerController
实例委托:
class PickerViewController: UIViewController, UIImagePickerControllerDelegate {
var pickerController = UIImagePickerController()
override func viewDidLoad() {
super.viewDidLoad()
pickerController.delegate = self
}
}
此外,最好不要发送发送给该委托人的picker
参数:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
...
picker.dismiss(animated: true, completion: nil)
}
答案 2 :(得分:1)
如果您的断点函数未在调用,那么我认为您尚未在viewDidLoad()中设置imagePicker委托
override func viewDidLoad() {
super.viewDidLoad()
imagePicker.delegate = self
}