I am building an app which takes the image from the UIImagePickerControllerSourceTypePhotoLibrary . When I select the Image I have to display the Image in another view with the Delete button . Please refer the below image . My intension is if you observe the photos app in the iPhone after selecting the image it is going to the fullImage view . Can we display the same in the app using the UIImagePickerController?
I have searched a lot but didn't get any solution . Is there any frameworks existing for showing full Image with the Delete symbol . I am trying to implement my own view, but it is taking much time to implement .
See this library
FGallery
There is the trash button which you are looking. You need to do only small changes for your requirement
You can get the selected image from your library, you have to dismiss your
UIImagePickerController and after that you need to create custom UIViewController and you have to present/push it to the user with saved picture:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissViewControllerAnimated:YES completion:^{}];
UIImage *_image = [info objectForKey:UIImagePickerControllerEditedImage];
UICustomViewController *custom = [[UICustomViewController alloc] init];
custom.MyImage = _image;
[self presentViewController:custom animated:YES completion:nil];
}
It's very simple solution and you don't needy to use any existing framework.
Apple doesn't actually allow you to delete from the photo library through an API. The user has to actually go to the Photos app and delete it manually themselves. Apple does allow you write to the photo library:
To save a still image to the user’s Saved Photos album, use the
UIImageWriteToSavedPhotosAlbum function.
To save a movie to the user’s Saved Photos album, use the UISaveVideoAtPathToSavedPhotosAlbum function.
But for deleting and editing/overriding an existing photo, Apple doesn't have anything like that right now.
Related
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.
i've been searching around the web but couldn't find an answer.
basically i wanna take two photos one right after the other.
i'm using UIImagePickerController to show a picker and implementing didFinishPickingMediaWithInfo.
when it gets called i'm checking my count so that if its one, i implement a block and pass it to dismissViewControllerAnimated like this:
if(1 == count) {
void (^simpleBlock)(void);
simpleBlock = ^{
[self useCamera];
};
[self dismissViewControllerAnimated:NO completion:simpleBlock];
}
it all seems to work fine, and even the useCamera method is called.
the problem is that the second time the picker shows i see all of its controls but i don't see on the screen the image from the camera.
any help would be appriciated.
i managed to work it out with replacing the call to useCamera with:
[self performSelector:#selector(useCamera) withObject:nil afterDelay:0.3];
i think my question has some relation to: iOS 7 UIImagePickerController has black preview
since the delay fixed the problem.
For you to save time. You can use available library out there. These are my good choices. CTAssetsPickerController ELCImagePickerController
UIImagePickerController helps to access the default camera app in iOS.
It will allow only limited functionalities like take picture/video, photo album.
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).
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.
I have tried to take a picture and save it to the photo library automatically with UIImagePicker and AVFoundation, but I couldn't make it work.
I would like to take the photo when the view appears, not showing the camera view to the user, and then use it as a simple image in the app.
Thanks
Apple actually has an entire guide devoted to this sort of thing, "Camera Programming Topics for iOS," with a subsection "Taking Pictures and Movies." There's even a sample project, "Photo Picker." Here's an excerpt, the action method for your take-a-picture button:
- (IBAction)cameraAction:(id)sender {
[self showImagePicker:UIImagePickerControllerSourceTypeCamera];
}
Note: It won't work unless [UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] returns YES, indicating that the device has a camera.