x正在同步, 请稍候查看


 收藏    我在用   0 人在用
 -  null

WPMediaPicker is an iOS controller that allows capture and picking of media assets.

 GitHub     下载

23    71    26    over 1 year前


CI Status

WPMediaPicker is an iOS controller that allows capture and picking of media assets.
It allows:
* Allows selection of multiple media objects in one go.
* Capture of new media while inside the picker.
* Use different data sources for the media library.
* Switch between different albums.
* Filtering by media types.
* Preview of media (images and video) in full screen.
* Show the media picker inside as a keyboard input view.
* Super quick and memory optimized



WPMediaPicker is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "WPMediaPicker"


To use the picker do the following:

Import header

#import <WPMediaPicker/WPMediaPicker.h>
WPNavigationMediaPickerViewController * mediaPicker = [[WPNavigationMediaPickerViewController alloc] init];
mediaPicker.delegate = self;
[self presentViewController:mediaPicker animated:YES completion:nil];

Implement didFinishPickingAssets delegate

The delegate is responsible for dismissing the picker when the operation completes. To dismiss the picker, call the dismissViewControllerAnimated:completion: method of the presenting controller responsible for displaying the WPNavigationMediaPickerController object. Please refer to the demo app.

- (void)mediaPickerController:(WPMediaPickerViewController *)picker didFinishPickingAssets:(NSArray<WPMediaAsset> *)assets
  [self dismissViewControllerAnimated:YES completion:nil];    

Other methods to display the picker

The example above shows the recommended way to show the picker in a modal. There are currently three available controllers to show the picker depending on your application needs:

How to configure the appearance of the picker

Just use the standard appearance methods from UIKIT. Here is an example how to configure the main components

//Configure navigation bar background color
[[UINavigationBar appearanceWhenContainedIn:[WPNavigationMediaPickerViewController class],nil] setBarTintColor:[UIColor colorWithRed:0/255.0f green:135/255.0f blue:190/255.0f alpha:1.0f]];
//Configure navigation bar items text color
[[UINavigationBar appearanceWhenContainedIn:[WPNavigationMediaPickerViewController class],nil] setTintColor:[UIColor whiteColor]];
//Configure navigation bar title text color
[[UINavigationBar appearanceWhenContainedIn:[WPNavigationMediaPickerViewController class],nil] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]} ];
//Configure background color for media scroll view
[[UICollectionView appearanceWhenContainedIn:[WPMediaCollectionViewController class],nil] setBackgroundColor:[UIColor colorWithRed:233/255.0f green:239/255.0f blue:243/255.0f alpha:1.0f]];
//Configure background color for media cell while loading image.
[[WPMediaCollectionViewCell appearanceWhenContainedIn:[WPMediaCollectionViewController class],nil] setBackgroundColor:[UIColor colorWithRed:243/255.0f green:246/255.0f blue:248/255.0f alpha:1.0f]];
//Configure color for activity indicator while loading media collection
[[UIActivityIndicatorView appearanceWhenContainedIn:[WPMediaCollectionViewController class],nil] setColor:[UIColor grayColor]];

How to use a custom data source for the picker

If you have a custom database of media and you want to display it using the WPMediaPicker you need to to implement the following protocols around your data:

You can view the protocols documentation for more implementation details.
After you have implemented it you can use it by simple doing the following:

self.customDataSource = [[WPCustomAssetDataSource alloc] init];
mediaPicker.dataSource = self.customDataSource;

Sample Project

To run the example project, clone the repo, and run pod install from the Example directory first.


  • ARC
  • Photos, AVFoundation, ImageIO
  • XCode 8 or above
  • iOS 8 or above


WordPress, mobile@automattic.com


WPMediaPicker is available under the GPL license. See the LICENSE file for more info.

No Reply at the moment.
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up