Skip to content

Commit

Permalink
Merge branch 'diehappy-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaoj committed Jan 7, 2017
2 parents cbde13c + 28b8002 commit 96b7f86
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Example/BSImagePicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
55E273E71BE004F2006006A7 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
49 changes: 24 additions & 25 deletions Example/BSImagePicker/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,30 @@ class ViewController: UIViewController {
}

@IBAction func showImagePickerWithSelectedAssets(_ sender: UIButton) {
// FIXME:
// let allAssets = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: nil)
// var evenAssetIds = [String]()
//
// allAssets.enumerateObjects { (asset, idx, stop) -> Void in
// if let asset = asset as? PHAsset , idx % 2 == 0 {
// evenAssetIds.append(asset.localIdentifier)
// }
// }
//
// let evenAssets = PHAsset.fetchAssets(withLocalIdentifiers: evenAssetIds, options: nil)
//
// let vc = BSImagePickerViewController()
// vc.defaultSelections = evenAssets
//
// bs_presentImagePickerController(vc, animated: true,
// select: { (asset: PHAsset) -> Void in
// print("Selected: \(asset)")
// }, deselect: { (asset: PHAsset) -> Void in
// print("Deselected: \(asset)")
// }, cancel: { (assets: [PHAsset]) -> Void in
// print("Cancel: \(assets)")
// }, finish: { (assets: [PHAsset]) -> Void in
// print("Finish: \(assets)")
// }, completion: nil)
let allAssets = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: nil)
var evenAssetIds = [String]()

allAssets.enumerateObjects({ (asset, idx, stop) -> Void in
if idx % 2 == 0 {
evenAssetIds.append(asset.localIdentifier)
}
})

let evenAssets = PHAsset.fetchAssets(withLocalIdentifiers: evenAssetIds, options: nil)

let vc = BSImagePickerViewController()
vc.defaultSelections = evenAssets

bs_presentImagePickerController(vc, animated: true,
select: { (asset: PHAsset) -> Void in
print("Selected: \(asset)")
}, deselect: { (asset: PHAsset) -> Void in
print("Deselected: \(asset)")
}, cancel: { (assets: [PHAsset]) -> Void in
print("Cancel: \(assets)")
}, finish: { (assets: [PHAsset]) -> Void in
print("Finish: \(assets)")
}, completion: nil)
}
}

4 changes: 2 additions & 2 deletions Pod/Classes/Controller/BSImagePickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ open class BSImagePickerViewController : UINavigationController {
/**
Default selections
*/
private var defaultSelections: PHFetchResult<PHAsset>?
open var defaultSelections: PHFetchResult<PHAsset>?

/**
Fetch results.
*/
private lazy var fetchResults: [PHFetchResult] = { () -> [PHFetchResult<PHAssetCollection>] in
open lazy var fetchResults: [PHFetchResult] = { () -> [PHFetchResult<PHAssetCollection>] in
let fetchOptions = PHFetchOptions()

// Camera roll fetch result
Expand Down

0 comments on commit 96b7f86

Please sign in to comment.