你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> IOS獲得體系相冊中照片的示例代碼

IOS獲得體系相冊中照片的示例代碼

編輯:IOS開發綜合

先來看看後果圖

上面話不若干,我們直接上代碼:

#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獲得體系相冊中照片的示例代碼】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved