question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Opening image picker from within modal

See original GitHub issue

When the image picker is triggered from within a page that was opened using showModal(), the picker is loaded behind the page. Is there any way to work around this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
iosdeveloper1001commented, Jul 25, 2019

I was facing the same issue with the error of window hierarchy, I Solved it by just adding a Timeout of 10 milliseconds.

let context = imagepicker.create({ mode: "single" });
this.startSelection(context);
public startSelection(context) {
		let _that = this;
		setTimeout(function() {
		context
			.authorize()
			.then(() => {
				return context.present();
			})
			.then((selection) => {
				selection.forEach(function (selected) {
					let source = new ImageSourceModule.ImageSource();
					if (source && source !== null) {
						source.fromAsset(selected).then((source) => {
						}, error => { });
					}
				});
			}).catch(function (e) {
				console.log(e);
			});
		}, 10);
	} 
1reaction
abhayastudioscommented, Mar 29, 2019

@mailiam @tbozhikov

Even with the latest version of this plugin, I am still not able to open the ImagePicker in an existing modal. Here is my example project that:

  • opens a modal
  • gets a reference from that Page (though ViewChild, but also tried through shownModally event)
  • pass the NativeElement property of that Page reference to ImagePicker create

It does open the ImagePicker but it will open an new modal on top of the existing one.

Note: the Page object I get does seem to be the top element, since its parent is undefined and it does contain the viewController property that this piece of code is looking for

Any ideas?

EDIT: is what I am seeing actually expected behavior? I was under the impression that the additional hostView parameter would allow the ImagePicker to open in the existing modal?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Present UIImagePickerController inside a modal view or form ...
In my iPad app I have this image picker and I would like to present it in a 500x500 modal view centred on...
Read more >
Modal & Inline - Image Picker 1.3 - HazzardWeb Docs
The fist option is to have the ImagePicker as a modal. For this you have to define the modal html a button that...
Read more >
Use an image picker - Expo Documentation
expo-image-picker provides the launchImageLibraryAsync() method that displays the system UI for choosing an image or a video from the device's media library. We ......
Read more >
How to pick images from Camera & Gallery in React Native app
In the above code, we will open an Image picker as you Click on “chooseImage” and will show the selected image on the...
Read more >
Example of Image Picker in React Native
To use ImagePicker we need to install react-native-image-picker dependency. To install this open the terminal and jump into your project using cd ProjectName....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found