123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- //
- // QBImagePickerController.m
- // QBImagePicker
- //
- // Created by Katsuma Tanaka on 2015/04/03.
- // Copyright (c) 2015 Katsuma Tanaka. All rights reserved.
- //
- #import "QBImagePickerController.h"
- #import <Photos/Photos.h>
- // ViewControllers
- #import "QBAlbumsViewController.h"
- @interface QBImagePickerController ()
- @property (nonatomic, strong) UINavigationController *albumsNavigationController;
- @property (nonatomic, strong) NSBundle *assetBundle;
- @end
- @implementation QBImagePickerController
- - (instancetype)init
- {
- self = [super init];
-
- if (self) {
- // Set default values
- self.assetCollectionSubtypes = @[
- @(PHAssetCollectionSubtypeSmartAlbumUserLibrary),
- @(PHAssetCollectionSubtypeAlbumMyPhotoStream),
- @(PHAssetCollectionSubtypeSmartAlbumPanoramas),
- @(PHAssetCollectionSubtypeSmartAlbumVideos),
- @(PHAssetCollectionSubtypeSmartAlbumBursts)
- ];
- self.minimumNumberOfSelection = 1;
- self.numberOfColumnsInPortrait = 4;
- self.numberOfColumnsInLandscape = 7;
-
- _selectedAssets = [NSMutableOrderedSet orderedSet];
-
- // Get asset bundle
- self.assetBundle = [NSBundle bundleForClass:[self class]];
- NSString *bundlePath = [self.assetBundle pathForResource:@"QBImagePicker" ofType:@"bundle"];
- if (bundlePath) {
- self.assetBundle = [NSBundle bundleWithPath:bundlePath];
- }
-
- [self setUpAlbumsViewController];
-
- // Set instance
- QBAlbumsViewController *albumsViewController = (QBAlbumsViewController *)self.albumsNavigationController.topViewController;
- albumsViewController.imagePickerController = self;
- }
-
- return self;
- }
- - (void)setUpAlbumsViewController
- {
- // Add QBAlbumsViewController as a child
- UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"QBImagePicker" bundle:self.assetBundle];
- UINavigationController *navigationController = [storyboard instantiateViewControllerWithIdentifier:@"QBAlbumsNavigationController"];
-
- [self addChildViewController:navigationController];
-
- navigationController.view.frame = self.view.bounds;
- [self.view addSubview:navigationController.view];
-
- [navigationController didMoveToParentViewController:self];
-
- self.albumsNavigationController = navigationController;
- }
- @end
|