i am new programming how ever i developing and application i wan`t to access all library image in my image view and slide the image and see it . like and any camera we see all images can any body suggest!
how to implement all library image in my view and slide it i am implementing this but through that i can access only single image.
picker = [[UIImagePickerController alloc]init];
picker.delegate=self;
[picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:picker animated:YES completion:NULL];
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
image=[info objectForKey:#"UIImagePickerControllerOriginalImage"];
[_imageview setImage:image];
[self dismissViewControllerAnimated:YES completion:NULL];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:NULL];
}
In oder to get all photo / assets from the native photo application you can use the Photos Framework. You can find the detailed documentation from this link
https://developer.apple.com/library/ios/documentation/Photos/Reference/Photos_Framework/index.html#//apple_ref/doc/uid/TP40014408
Related
I have everything i want working up to the view you can see in the picture, i don't want the image to load on the same screen, how can i get it to load in a new screen. i have tried a few tutorials, i have had no luck as yet
The image that has been loaded from the gallery is the brick wall in the background.
the reason i want to load it in a new screen is so i can put a new toolbar that will allow me to drag images and overlay them on top of the image selected from taller or taken with the camera
Thanks in advance and sorry for asking about something that sounds so simple, I'm just very new to all this.
http://imageshack.com/a/img845/4808/9lz8.png
- (IBAction)selectPhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
}
#pragma mark - Image Picker Controller delegate methods
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:NULL];
}
How do i open new screen when didFinishPickingMediaWithInfo
If you need to see me more code please let me know which, I'm not sure what code you need to see :) thank you for your reply.
If you want the image to load on a new screen, you'll need to create a second viewController, and add an imageView to that viewController.
then in your didFinishPicking method, instead of setting the image to the imageView of the current ViewController, instantiate a new imageController, set the imageView property of the new viewController, and then push your new viewController onto the navigation stack if you're using a navigation controller. If you're not using a navigation controller, you could just push the second view controller modally.
So in your didFinishPicking method it would be
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
NewViewController *newViewController = [[NewViewController alloc] init];
newViewController.imageView.image = chosenImage; //or whatever the imageView property is called of your new view controller
[self presentViewController:newViewController animated:YES completion:nil];
(I haven't tested this code - it's off the top of my head so reader caution advised and this is the modal method)
Let's try:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:^{
// I think you should not call `presentViewController` newViewController at this screen because it maybe be destroyed
// So, call newViewController at parentClass by delegate of block
// and assign new image to the screen which need to show
}];
}
I'm writing an app that allows the user to take a picture and then shows it in an image view.
I get that I need to write a line of code similar to the following: _imageView.image = picker.image;, but I'm not sure what I need to substitute for picker.image. That is what I currently have and it gives me an error.
Basically, what I'm asking is how do I reference the picture that was just taken? Where does this picture go (in memory?) after you take it? How can I reference it later (like for displaying and saving and that sort of stuff)?
I've already read the official Apple documentation and looked at a few tutorials and the answer doesn't seem to be in any of them. As I've mentioned in previous posts, I tend to have a lot of trouble parsing the Apple documentation, so it's been mostly useless for me.
Thank you!
I use the following delegate method to get whatever picture a user picked from the photo picker view
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:false completion:nil];
image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
}
call the cameraTapped method on tapping your camera button
-(IBAction)cameraTapped:(id)sender
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
[imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
else
[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[imagePickerController setDelegate:self];
[self presentViewController:imagePickerController animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// photo
_imageView.image = info[UIImagePickerControllerOriginalImage]];
[self dismissViewControllerAnimated:YES completion:nil];
}
I'm using the code below to retrieve an image from the iphone photo library. self.selectedImageView.image is an image view located on top of the view of the current view controller. Everything in xcode seems linked correctly; the image view is wired and so fourth.
Problem:
After selecting an image I can see that this method is called but the new image does not update. The image view is completely blank.
Question: Is their some sort of refreshing that needs to take place after reassigning a new image to an image view?
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSLog(#"image selected");
[picker dismissViewControllerAnimated:YES completion:NULL];
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.selectedImageView.image = chosenImage;
}
Try using the key UIImagePickerControllerOriginalImage instead. The key your currently using, UIImagePickerControllerEditedImage, is for accessing images that the user has edited.
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
// Get the image first then dismiss the controller.
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[self dismissViewControllerAnimated:YES completion:nil];
self.selectedImageView.image = chosenImage;
}
may this help you and above posted code by Gyanendra singh also correct even you can follow his code also.
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
//here we are storing the image in uiimage after selecting from library
UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];
//set image to image view
[imageView setImage:image];
//after selecting photo from library dismiss photo library
[self dismissModalViewControllerAnimated:YES];
}
I have 2 Storyboards for iPhone and iPad.
From a Button on a UITableviewcontroller I want to select an Image with a UIImagepicker.
On the iPad this works fine, on the iPhone the UIImagepicker is shown for very short moment and then he disappears.
The calling code is the same for iPad an iPhone and as I can see the storyboards are idenitical. Im looking for hours and cannot see why the Imagepicker disappears on iPhone and on iPad not.
Has anyone an idea for this behaviour? What can be the reason why the UIImagePicker disappears without doing anything?
- (void) go {
UIImagePickerController *ipc = [[UIImagePickerController alloc]init];
[ipc setSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum];
ipc.delegate=self;
[self presentViewController:ipc animated:YES completion:^{}];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
NSLog(#"imagePickerControllerDidCancel");
[self dismissViewControllerAnimated:YES completion:^{}];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self.navigationController dismissViewControllerAnimated:NO completion:^{}];
[self dismissViewControllerAnimated:NO completion:^{}];
NSLog(#"didFinishPickingMediaWithInfo");
}
On iPhone the log "imagePickerControllerDidCancel" is never shown!
Store the picker in a strong class property instead of a local variable, like this:
#property(nonatomic, strong) UIImagePickerController *imagePickerController
...
- (void) go {
self.imagePickercontroller = [[UIImagePickerController alloc]init];
self.imagePickercontroller.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
self.imagePickercontroller.delegate=self;
[self presentViewController:ipc animated:YES completion:nil];
}
Here is my code:
-(void) takePhoto
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
//imagePickerController.editing = YES;
imagePickerController.allowsEditing=YES;
imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:NULL];
}
#pragma mark - Image picker delegate methods
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:NO completion:nil];
[self.Picture setImage:[info objectForKey:UIImagePickerControllerOriginalImage]];
}
and I have implemented the delegates
UINavigationControllerDelegate,UIImagePickerControllerDelegate
The image is taken, I can see the move and scale box, but when I move it the box returns to the initial position - likes it bounces back.
Why is that?
Looks like this is caused because you are requesting the UIImagePickerControllerOriginalImage, according to the documentation this returns "the original, uncropped image selected by the user."
Try changing this to UIImagePickerControllerEditedImage.
https://developer.apple.com/library/ios/documentation/uikit/reference/UIImagePickerControllerDelegate_Protocol/UIImagePickerControllerDelegate/UIImagePickerControllerDelegate.html#//apple_ref/doc/constant_group/Editing_Information_Keys
Edit: Actually after re-reading the question a couple of times if the problem is occurring in the picker itself this probably won't help.