iphone how to go to the image gallery after taking

2019-04-12 17:37发布

Hi all I am implementing the following code to take a photo through my application

[[[UIApplication sharedApplication] keyWindow] setRootViewController:picker];
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    [self presentModalViewController:picker animated:NO];

Can anyone tel me How I can go to the photo gallery after the user takes the photo and not return to the application.

3条回答
别忘想泡老子
2楼-- · 2019-04-12 18:19

If you want to shoot a picure use this code -

UIImagePickerController* picker = [[UIImagePickerController alloc] init];
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.delegate = self;
    picker.allowsImageEditing = YES;
    [[self navigationController] presentModalViewController:picker animated:YES];

If you want to go to photo gallery and wants to select a photo from there use this code -

UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
picker.allowsImageEditing = YES;
[[self navigationController] presentModalViewController:picker animated:YES];

Notice the difference between the picker's sourceType

查看更多
祖国的老花朵
3楼-- · 2019-04-12 18:29
UIImagePickerControllerSourcePhotoLibrary
查看更多
来,给爷笑一个
4楼-- · 2019-04-12 18:34

i think you might want to try this

How to open camera while I click the UIButton in iPhone?

or i really didn't get the question

Edit: Well you can use the same code with UIImagePickerControllerSourcePhotoLibrary after taking the pic from camera. I mean call this Function with UIImagePickerControllerSourcePhotoLibrary then it will take you to photo Library and then back again to your application.

查看更多
登录 后发表回答