On UIWebView not able to select photo? - ios

I am loading URL on UIWebView on that URL photo select option is there, when I click on "choose file" photo select alert will come like
below in image :---
/Users/ArjunSinghBaghel/Desktop/Screen Shot 2017-02-13 at 11.06.02 PM.png
but when I click on "Photo Library" that page going to disappear.
Please help my out ..
Thanks in advance.

You probably need to set proper permissions in Info.plist file. Namely Privacy - Photo Library Usage Description and Privacy - Camera Library Usage Description.
Alternatively, you can use WKWebView. I just tested Swift implementation in Swift Playgrounds on my iPad with IOS 10 and it is working fine. Please see https://gist.github.com/kiritmodi2702/b8a674bb66803c1397cab55030ae2c54.

As the warning logged in debugger suggests, the UIImagePickerController is not getting invoked appropriately.
Consider the example,
- (void)takePhoto:(UIButton *)sender{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
[self presentViewController:picker animated:YES completion:nil];
}
Confirm whether the self being used is a subclass of UIViewController which has been added to the UINavigatorController Bar stack. In the current scenario, it appears self is a UIView instance.

Related

UIImagePickerController the take photo button not work, until long press or click many times

I just want to take a picture from camera through my app. But present to the UIImagePickerController, the take photo button does't work, i can see the button is pressed style up and down.But no photo is captured.Until i long press the take button or click many times, then a photo can be captured.
in my project, the current UIViewController obey the UIImagePickerControllerDelegate and UINavigationControllerDelege. But it still does'n make a difference.
the code like this below:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:nil];
I try add the code:
picker.modalPresentationStyle = UIModalPresentationCurrentContext;
it does'n work neither.
Please help me. I search for solutions many times all around, but no one can solve my problem.
Thanks!
This question took me much time on it, but i still could not solve after debug many times. So i finally decided to custom the camera. I found a wonderful code in github website, the link is here
anyone interested can have a look.
Finally, i found another similar scene: https://forums.developer.apple.com/message/232522#232522

How to reload UIImagePickerController?

I use UIImagePickerController to get an image needed in my app.
// ...
picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
// ...
But I found a problem in my process to get an image with UIImagePickerController.
When UIImagePickerController object's view is on device screen, user can make my app go to background and take a picture with other apps. User backs to my app then, my app still shows UIImagePickerController object's view. But the contents in Photo library is not changed unless user reopen UIImagePickerController.
I need to reload UIImagePickerController object's view. How to do it?
This question is about reloading UIImagePickerController, not app foreground notification.
Thank you for your attention.
Once you get the notification you can destroy and recreate the picker. This will refresh the images available but will lose any current selection / scroll position. As such, it probably isn't a good idea to always reload (you can use the assets library to check if the image count changed).

UIImagePickerController shows last picture taken instead of camera input

I'm having a strange behaviour within my app.
For taking pictures i'm using the following pretty standard code for displaying the UIImagePickerController:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:nil];
It works perfectly fine the first time I tap the button which calls this action. The strange behaviour starts when I tap that button again. The UIImagePickerController starts again BUT it doesnt show the input from the camera anymore. It shows the last picture I've taken.
More Details of this state:
Tapping on the image shows the yellow square of the auto focus. (which it actually uses to focus the camera correctly)
When I tap on the ImageCapture button -> the correct image is taken and presented on the screen.
If I take a picture and press 'Retake' the regular camera image is presented as input.
More weirdness: It has nothing to do with the iPad I'm using. Creating a new example app which only has button which calls the code from above everything works perfectly fine.
I assume it has something to do with the configuration of the app. Therefore I checked everything but could not find any differences which may cause this issue.
Thanks in advance for any advice!
Update:
I do implement the UIImagePickerControllerDelegate in order to dismiss the UIImagePickerController.
In reading the Apple documentation on UIImagePickerController doc here it states that "When the user taps a button to pick a newly-captured or saved image or movie, or cancels the operation, dismiss the image picker using your delegate object. For newly-captured media, your delegate can then save it to the Camera Roll on the device. For previously-saved media, your delegate can then use the image data according to the purpose of your app." Maybe you need to implement the UIImagePickerContriollerDelegate protocol methods and properly dismiss the existing UIImagePickerController object. See UIImagePickerControllerDelegate
I finally did find the issue: It was a category on UIViewController I used somewhere else in the project. As soon as I compiled it with my project, the UIImagePickerController acted weird. So I think I somehow managed to use a method name which is also used internally by UIImagePickerController. It still confuses me a little since the category wasn't used on the UIImagePickerController at all.

UIImagePickerController and External display

I am writing an iPad kiosk-type application that allows a visitor to record a video using the front facing camera and view existing videos in the Camera Roll that are targeting an External monitor. I am just learning XCode, and working in Xcode 4.4.1 targeting iOS 5. It seems like a lot has changed recently and this is making it much harder to learn so I am trying to keep things as simple as possible, that's why I am using UIImagePicker.
Everything is working as I wish, with one exception – I am not able to toggle between the external display and the iPad as I want. When the user records a video, it is full screen on the iPad. That's fine, however after they stop recording, the video is immediately sent to the external display for approval and a placeholder image is left in the UIPopover. What I would rather see/do is either keep the video preview full screen on the iPad, or target the video to the UIPopover.
The reason is that the external display is not easily viewable from where the user is accessing the iPad. Therefore, they are being asked to approve (click Use) on something they can't really see. It would be much better to keep it on the iPad. The code below is what I have used to allow recording.
Everything else works great, I want the user to select videos from the Library and display on the External monitor, and since that's the default behavior it works fine.
The closest answer I could find so far is this: UIImagePickerController in an existing UIPopoverController
Is there a simple way to disable the external display or keep the video preview from being sent?
- (IBAction)useCameraRoll:(id)sender
{
if([self.popoverController isPopoverVisible]) {
[self.popoverController dismissPopoverAnimated:YES];
} else {
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeMovie, nil];
imagePicker.allowsEditing = NO;
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
//self.popoverController = [[UIPopoverController alloc] setContentViewController:animated];
self.popoverController.delegate = self;
[self.popoverController
presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
newMedia = NO;
}
}
}
Coincidentally, I have been working on a similar kiosk app with an iPad. In my case it utilizes some Augmented Reality to show relevant content on the external display. I use the iPad screen as a configuration panel for the augmented reality experience.
Best way, that I found, to approach this, would be to use separate windows with the two UIScreens for each of the displays. This enables you to craft the experience properly. I am not sure if you are using this approach already, but if you aren't, then this is the way to go.
To get started you can read the ExternalDisplay code sample. From the excerpt:
From the ExternalDisplay sample code in the iOS Developer Library:
To display content on an external display, do the following:
Use the screens class method of the UIScreen class to determine if an external display is available.
If an external screen is available, get the screen object and look at the values in its availableModes property. This property contains
the configurations supported by the screen.
Select the UIScreenMode object corresponding to the desired resolution and assign it to the currentMode property of the screen
object.
Create a new window object (UIWindow) to display your content.
Assign the screen object to the screen property of your new window.
Configure the window (by adding views or setting up your OpenGL ES rendering context).
Show the window.
Also, the UIScreen documentation is quitehelpful.

UIImagePickerController appears but camera doesn't start on iOS 5

I have an app where I present a UIImagePickerController with source type UIImagePickerControllerSourceTypeCamera. Everything works fine unless I leave the app and come back (multitasking is enabled so the app comes back right where it left off) and I present the UIImagePickerController again. It appears on screen but the camera never shows, the animation where the camera is revealed never happens, here is a screenshot:
If I press cancel and present the UIImagePickerController again, the camera will show up fine. So the only time this problem occurs is the first time I present the UIImagePickerController after coming back to the app. Anyone know why this is happening? I'm coding for iOS 5
I'm presenting the UIImagePickerController with:
[self presentViewController:capturePhotoPicker animated:YES completion:nil];
and dismissing it with:
[self dismissViewControllerAnimated:YES completion:nil];
I am using the same UIImagePickerController object each time I present it
I had exactly the same problem and then realized I wasn't releasing the UIImagePickerController after presenting it. The camera now works fine first-time after leaving and returning to the app.
So this is my exact code:
UIImagePickerController *takePhotoController = [[UIImagePickerController alloc] init];
takePhotoController.sourceType = UIImagePickerControllerSourceTypeCamera;
takePhotoController.delegate = self;
[self presentModalViewController:takePhotoController animated:YES];
[takePhotoController release];
It's one of those problems you can spend ages on, and the solution is not that obvious (well, it wasn't to me), so I hope this helps some people!
if you change the -(void)viewDidLoad to - (void)viewDidAppear:(BOOL)animated it fixes the problem. I've spent the last 2 weeks trying to figure this out

Resources