欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

IOS獲取系統(tǒng)相冊(cè)中照片的示例代碼

 更新時(shí)間:2016年09月05日 09:44:55   投稿:daisy  
在大家的日常開發(fā)中,經(jīng)常會(huì)遇到有的app需要從系統(tǒng)相冊(cè)中獲取圖片,如設(shè)置用戶頭像等,下面這篇文章給大家分享這個(gè)功能的實(shí)現(xiàn),有需要的可以參考借鑒。

先來看看效果圖

下面話不多少,我們直接上代碼:

#import "ViewController.h"

@interface ViewController ()<UINavigationControllerDelegate,UIImagePickerControllerDelegate>

@property (weak, nonatomic) IBOutlet UIImageView *IconView;

@end

@implementation ViewController

- (IBAction)chooseImage {

  //彈出系統(tǒng)相冊(cè)
  UIImagePickerController *pickVC = [[UIImagePickerController alloc] init];

  //設(shè)置照片來源
  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

總結(jié)

以上就是IOS如何獲取系統(tǒng)相冊(cè)照片的示例代碼,有需要的朋友們可以直接用,對(duì)大家的開發(fā)還是很有幫助的,如果大家有疑問可以留言交流。

相關(guān)文章

最新評(píng)論