GMImagePicker.Xamarin
2.3.0
See the version list below for details.
dotnet add package GMImagePicker.Xamarin --version 2.3.0
NuGet\Install-Package GMImagePicker.Xamarin -Version 2.3.0
<PackageReference Include="GMImagePicker.Xamarin" Version="2.3.0" />
paket add GMImagePicker.Xamarin --version 2.3.0
#r "nuget: GMImagePicker.Xamarin, 2.3.0"
// Install GMImagePicker.Xamarin as a Cake Addin #addin nuget:?package=GMImagePicker.Xamarin&version=2.3.0 // Install GMImagePicker.Xamarin as a Cake Tool #tool nuget:?package=GMImagePicker.Xamarin&version=2.3.0
GMImagePicker.Xamarin
An image & video picker supporting multiple selection and several customizations. Powered by the iOS 8 Photo framework.
This is a 1-to-1 port of the origina GMImagePicker component made by Guillermo Muntaner from Objective-C to C# for Xamarin.iOS. The original source can be found here: github.com/guillermomuntaner/GMImagePicker. This port is published with kind permission from Guillermo Muntaner.
Screenshots
Features
- Allows selection of multiple photos and videos, even from different albums.
- Optional single selection mode.
- Optional camera access.
- Optional bottom toolbar with information about users selection.
- Full and customizable acces to smart collections(Favorites, Slo-mo or Recently deleted).
- Filter by collections & albums.
- Filter by media type.
- Customizable colors, fonts and labels to ease branding of the App.
- By default mimics UIImagePickerController in terms of features, appearance and behaviour.
- Dynamically sized grid view, easy to customize and fully compatible with iPhone 6/6+ and iPad.
- Works in landscape orientation and allow screen rotation!
- It can be used as Popover on iPad, with customizable size.
- Fast & small memory footprint powered by PHCachingImageManager.
- Full adoption of new iOS8 PhotoKit. Returns and array of PHAssets.
- Ability to add additional toolbar items to the toolbar
Usage
Installation
Manually
Clone or download solution and use GMImagePicker.Xamarin csproj in your solution.
Nuget
Get GMImagePicker.Xamarin package from Nuget and add it to your iOS application project.
Install-Package GMImagePicker.Xamarin
Initialize the picker, hook up events and present it
var picker = new GMImagePickerController ();
picker.FinishedPickingAssets += (sender, args) => {
Console.WriteLine ("User finished picking assets. {0} items selected.", args.Assets.Length);
};
await PresentViewControllerAsync (picker, true);
You can also implement optional an optional event handler for the Canceled
event
picker.Canceled += (sender, args) { Console.WriteLine ("user canceled picking assets"); };
Customization
Before presenting the picker, you can customize some of its properties
...
//Display or not the selection info Toolbar:
picker.DisplaySelectionInfoToolbar = true;
//Display or not the number of assets in each album:
picker.DisplayAlbumsNumberOfAssets = true;
//Customize the picker title and prompt (helper message over the title)
picker.Title = "Custom title";
picker.CustomNavigationBarPrompt = "Custom helper message!";
//Customize the number of cols depending on orientation and the inter-item spacing
picker.ColsInPortrait = 3;
picker.ColsInLandscape = 5;
picker.MinimumInteritemSpacing = 2.0f;
//You can pick the smart collections you want to show:
picker.CustomSmartCollections = new [] { PHAssetCollectionSubtype.AlbumRegular, PHAssetCollectionSubtype.AlbumImported };
//Disable multiple selecion
picker.AllowsMultipleSelection = false;
//Show a promt to confirm single selection
picker.ConfirmSingleSelection = true;
picker.ConfirmSingleSelectionPrompt = "Do you want to select the image you have chosen?";
//Camera integration
picker.ShowCameraButton = true;
picker.AutoSelectCameraImages = true;
//Select the media types you want to show and filter out the rest
picker.MediaTypes = new [] { PHAssetMediaType.Image };
//Switch the sort order of the photos grid
picker.GridSortOrder = SortOrder.Descending; // (=newest on top); SortOrder.Ascending (oldest on top) is the default
//UI color & text customizations
picker.PickerBackgroundColor = UIColor.Black;
picker.PickerTextColor = UIColor.White;
picker.ToolbarBarTintColor = UIColor.DarkGray;
picker.ToolbarTextColor = UIColor.White;
picker.ToolbarTintColor = UIColor.Red;
picker.NavigationBarBackgroundColor = UIColor.Black;
picker.NavigationBarTextColor = UIColor.White;
picker.NavigationBarTintColor = UIColor.Red;
picker.PickerFontName = "Verdana";
picker.PickerBoldFontName = "Verdana-Bold";
picker.PickerFontNormalSize = 14.0f;
picker.PickerFontHeaderSize = 17.0f;
picker.PickerStatusBarStyle = UIStatusBarStyle.LightContent;
picker.UseCustomFontForNavigationBar = true;
//Custom or additional toolbar items
picker.AdditionalToolbarItems = new UIBarButtonItem[]
{
new UIBarButtonItem(UIBarButtonSystemItem.Bookmarks),
new UIBarButtonItem("Custom", UIBarButtonItemStyle.Bordered, (s, e) => { Console.WriteLine("test"); })
};
Use it as popover on iPad
Also works as Popover on the iPad! (with customizable size)
This code works in both iPhone & iPad
...
var picker = new GMImagePickerController ();
picker.Title = "Custom title";
picker.CustomNavigationBarPrompt = "Custom helper message!";
picker.ColsInPortrait = 3;
picker.ColsInLandscape = 5;
picker.MinimumInteritemSpacing = 2.0f;
picker.ModalPresentationStyle = UIModalPresentation.Popover;
var popPC = picker.PopoverPresentationController;
popPC.PermittedArrowDirections = UIPopoverArrowDirection.Any;
popPC.SourceView = _gmImagePickerButton;
popPC.SourceRect = _gmImagePickerButton.Bounds;
ShowViewController(picker, null);
Minimum Requirement
Xamarin Studio / Visual Studio, Xamarin.iOS and iOS 8+
License
The MIT License (MIT)
Copyright (c) 2016 Roy Cornelissen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
Xamarin.iOS | xamarinios10 is compatible. |
-
Xamarin.iOS 1.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.5.1 | 198,489 | 12/13/2020 |
2.5.0 | 54,319 | 9/23/2020 |
2.4.0 | 7,182 | 7/17/2020 |
2.3.6 | 13,603 | 4/20/2020 |
2.3.5 | 21,551 | 12/1/2019 |
2.3.4 | 25,989 | 6/7/2019 |
2.3.3 | 6,313 | 4/12/2019 |
2.3.2 | 23,309 | 11/16/2018 |
2.3.1 | 7,922 | 8/29/2018 |
2.3.0 | 1,316 | 8/17/2018 |
2.2.3 | 902 | 8/16/2018 |
2.2.2 | 2,418 | 7/20/2018 |
2.1.0 | 17,180 | 3/12/2018 |
2.0.1 | 1,315 | 12/6/2017 |
2.0.0 | 1,816 | 9/29/2017 |
1.0.1 | 1,501 | 5/3/2017 |
1.0.0 | 2,398 | 9/28/2016 |
0.0.10 | 1,518 | 7/21/2016 |
0.0.9 | 1,339 | 7/7/2016 |
0.0.8 | 1,306 | 4/20/2016 |
0.0.7 | 1,280 | 4/14/2016 |
0.0.6 | 1,289 | 4/12/2016 |
0.0.5 | 1,169 | 3/30/2016 |
0.0.4 | 1,332 | 3/30/2016 |
0.0.3 | 1,295 | 3/25/2016 |
0.0.2 | 1,062 | 3/25/2016 |
[2.3.0]
- Fixed #33: Add voiceover hints for image selection/deselection in GMGridViewController. Thanks Seara Chen for the PR!
[2.2.3]
- Minor fix: replaced use of deprecated API method call
- Switched to VSTS for CI builds
[2.2.2]
- Fixed crash #31 that would occur when taking a screenshot after having selected an image. Thanks Alex for the repo.
[2.2.1]
- Fixed crash that could happen in certain scroll position while pressing camera button. Thanks Ivan for the PR!
[2.2.0]
- Fixed #25: Photos in iCloud collections were not displayed
[2.1.0]
- Fixed #22: Added support for recording new videos with camera button (Thanks to Karim El Jed for the PR)
- Fixed #19: Added support for custom additional UIToolbarItems (Thanks to Armin (@pragmatrix) for the PR)
- Bugfix for a possible NullReferenceIssue (Thanks to Armin (@pragmatrix) for the PR)
[2.0.1]
- Fixed #18: inaccurate item count in album overview (Thanks to Erik Rodriguez for finding the cause)
[2.0.0]
- iOS 11 compatibility (Thanks to Lennard Sprong for the PR)
- Fixed high memory pressure issues (Thanks to Rolf van Kuijen for the PR)
- New hi-res image resources, including @3x size
- Feature toggle for "AllowEditingCameraImages"
[1.0.1]
-Fixes #10: Crash when a library is empty (Thanks to Rolf van Kuijen for the PR)
[1.0.0]
-Bumped version to 1.0.0
-Fix for older devices that were unable to render highest quality images (Thanks to Rolf van Kuijen for the PR)
[0.0.10]
-Fixed issue [#5]: Navigation bar does not show images behind it blurred (translucent)
-Camera button image now takes tintcolor set via GMImagePicker.CameraButtonTintColor property
-Fixed tint and background colors for navigationbar and toolbar
-Merged PR [#8] No longer setting the navigation bar background and shadow image
[0.0.9]
-Fixed issue [#7]: Invalid registrar for GMGridViewCell.ctor(CGRect frame)
[0.0.8]
-Fixed issue [#1]: Toolbar gets hidden due to wrong evaluation of selection
-Fixed issue [#2]: Auto selection behaviour after creating a new picture with the camera was incorrect
[0.0.7]
-User is taken directly to Settings app to enable camera / photos access.
[0.0.6]
-Added error messages and graceful handling of situations when the user has denied access to images and/or camera.
-Changed default sort order of photo grid to Creation Date Ascending to resemble native Photos app (this is customizable).
[0.0.5]
-Asset preselection now works as expected.
[0.0.4]
-Fixed loading of resource images in GMImagePicker DLL.
[0.0.3]
-Cleaned up the public API as to not cause confusion about the API entry and extension points.
[0.0.2]
-First version, feature parity with the original GMImagePicker version 0.0.2