GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - itheima-developer/HMImagePicker: 轻量级图像选择框架

BranchesTags
Open more actions menu

Latest commit

 

History

59 Commits
59 Commits

Folders and files

NameName
Last commit message
Last commit date
HMImagePicker.xcodeproj
HMImagePicker.xcodeproj
 
 
HMImagePicker
HMImagePicker
 
 
screenshots
screenshots
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
HMImagePicker.podspec
HMImagePicker.podspec
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

HMImagePicker

Build Status CocoaPods Compatible Platform

轻量级图像选择框架

功能

  • 仿微信照片选择功能,支持横竖屏
  • 与 UIImagePickerController 几乎完全一致的接口调用方式,上手容易
  • 使用 Photos 框架异步加载图片,内存消耗低

屏幕截图

系统支持

  • iOS 8.0+
  • Xcode 7.0

安装

CocoaPods

  • 进入终端,cd 到项目目录,输入以下命令,建立 Podfile
$ pod init
  • 在 Podfile 中输入以下内容:
platform :ios, '8.0'
use_frameworks!

target 'ProjectName' do
pod 'HMImagePicker'
end
  • 在终端中输入以下命令,安装或升级 Pod
# 安装 Pod,第一次使用
$ pod install

# 升级 Pod,后续使用
$ pod update

使用

Objective-C

  • 导入框架
@import HMImagePicker;
  • 在私有扩展中定义属性
@interface MainViewController () <HMImagePickerControllerDelegate>
/// 选中照片数组
@property (nonatomic) NSArray *images;
/// 选中资源素材数组,用于定位已经选择的照片
@property (nonatomic) NSArray *selectedAssets;
@end
  • 在选择按钮的方法中,实现以下代码
- (IBAction)clickSelectPhotoButton {
    HMImagePickerController *picker = [[HMImagePickerController alloc] initWithSelectedAssets:self.selectedAssets];

    // 设置图像选择代理
    picker.pickerDelegate = self;
    // 设置目标图片尺寸
    picker.targetSize = CGSizeMake(600, 600);
    // 设置最大选择照片数量
    picker.maxPickerCount = 9;

    [self presentViewController:picker animated:YES completion:nil];
}
  • 遵守协议
@interface MainViewController () <HMImagePickerControllerDelegate>
  • 实现协议方法
#pragma mark - HMImagePickerControllerDelegate
- (void)imagePickerController:(HMImagePickerController *)picker
      didFinishSelectedImages:(NSArray<UIImage *> *)images
               selectedAssets:(NSArray<PHAsset *> *)selectedAssets {

    // 记录图像,方便在 CollectionView 显示
    self.images = images;
    // 记录选中资源集合,方便再次选择照片定位
    self.selectedAssets = selectedAssets;

    [self.collectionView reloadData];

    [self dismissViewControllerAnimated:YES completion:nil];
}

About

轻量级图像选择框架

Resources

Readme
MIT license
Activity
Custom properties

Stars

138 stars

Watchers

10 watching

Forks

46 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.