先來看看後果圖

上面話不若干,我們直接上代碼:
#import "ViewController.h"
@interface ViewController ()<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
@property (weak, nonatomic) IBOutlet UIImageView *IconView;
@end
@implementation ViewController
- (IBAction)chooseImage {
//彈出體系相冊
UIImagePickerController *pickVC = [[UIImagePickerController alloc] init];
//設置照片起源
pickVC.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
pickVC.delegate = self;
[self presentViewController:pickVC animated:YES completion:nil];
}
#pragma mark - UIImagePickerControllerDelegate
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
UIImage *photo = info[UIImagePickerControllerOriginalImage];
UIImageView *imageV = [[UIImageView alloc] init];
imageV.frame = self.IconView.frame;
imageV.image = photo;
imageV.userInteractionEnabled = YES;
[self.view addSubview:imageV];
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
總結
以上就是IOS若何獲得體系相冊照片的示例代碼,有須要的同伙們可以直接用,對年夜家的開辟照樣很有贊助的,假如年夜家有疑問可以留言交換。
【IOS獲得體系相冊中照片的示例代碼】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!