public var assetBundle

This commit is contained in:
KazukiTanaka 2017-05-09 16:27:35 +09:00
parent 4536b5a2d9
commit c0c34eae5d
44 changed files with 244 additions and 6 deletions

View File

@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
@ -32,6 +42,16 @@
"filename" : "180.png",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",

View File

@ -29,6 +29,7 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController
Cell(title: "Large thumbnail", selector: #selector(DemoListViewController.showLargeThumbnailPicker)),
Cell(title: "No toolbar", selector: #selector(DemoListViewController.showNoToolbarPicker)),
Cell(title: "Disable to pick assets", selector: #selector(DemoListViewController.showDisableToPickAssetsPicker)),
Cell(title: "Custom UI", selector: #selector(DemoListViewController.showCustomUIPicker)),
]
override func viewDidAppear(_ animated: Bool) {
@ -123,6 +124,15 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController
present(picker, animated: true, completion: nil)
}
@objc
func showCustomUIPicker() {
let picker = NohanaImagePickerController()
picker.delegate = self
picker.assetBundle = Bundle.main
present(picker, animated: true, completion: nil)
}
// MARK: - NohanaImagePickerControllerDelegate
func nohanaImagePickerDidCancel(_ picker: NohanaImagePickerController) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2016 nohana, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"albumlist.title" = "Photos📗";
"albumlist.empty.message" = "No Photos🤔";
"albumlist.empty.description" = "Take some photos with Camera app.";
"albumlist.moment.title" = "Moment";
"toolbar.title.nolimit" = "Selected : %ld";
"toolbar.title.haslimit" = "Selected Items: %ld / %ld";

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2016 nohana, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"albumlist.title" = "アルバム📗";
"albumlist.empty.message" = "アルバムに\n写真がありません🤔";
"albumlist.empty.description" = "カメラで写真を撮影しましょう";
"albumlist.moment.title" = "日付から選択";
"toolbar.title.nolimit" = "%ld枚選択中";
"toolbar.title.haslimit" = "%ld枚選択中最大%ld枚";

View File

@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
3569CAA81EC1918E000C41C0 /* NohanaImagePicker.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3569CAA41EC1918E000C41C0 /* NohanaImagePicker.strings */; };
3569CAA91EC1918E000C41C0 /* NohanaImagePicker.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3569CAA61EC1918E000C41C0 /* NohanaImagePicker.xcassets */; };
F202573A1C7343D20069B33A /* ImageName.swift in Sources */ = {isa = PBXBuildFile; fileRef = F20257391C7343D20069B33A /* ImageName.swift */; };
F202573C1C7418920069B33A /* PickedAssetList.swift in Sources */ = {isa = PBXBuildFile; fileRef = F202573B1C7418920069B33A /* PickedAssetList.swift */; };
F208E5541CD7370B00FFC9F6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F208E5531CD7370B00FFC9F6 /* AppDelegate.swift */; };
@ -21,7 +23,7 @@
F218D7DE1C6C3A5B001FCED1 /* AlbumCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F218D7DD1C6C3A5B001FCED1 /* AlbumCell.swift */; };
F23554261C69D19C00796DCA /* NohanaImagePicker.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F23554251C69D19C00796DCA /* NohanaImagePicker.storyboard */; };
F23554281C69D5DB00796DCA /* NohanaImagePickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F23554271C69D5DB00796DCA /* NohanaImagePickerController.swift */; };
F237249B1C6DCF96005D1E8A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F237249A1C6DCF96005D1E8A /* Images.xcassets */; };
F237249B1C6DCF96005D1E8A /* NohanaImagePicker.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F237249A1C6DCF96005D1E8A /* NohanaImagePicker.xcassets */; };
F23CC89E1CB745C800BCE443 /* ActivityIndicatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = F23CC89D1CB745C800BCE443 /* ActivityIndicatable.swift */; };
F24EB6901C68AEED0002EC86 /* AlbumListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F24EB68F1C68AEED0002EC86 /* AlbumListViewController.swift */; };
F25C10C21C8ED9BF007453C3 /* MomentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F25C10C11C8ED9BF007453C3 /* MomentViewController.swift */; };
@ -71,6 +73,9 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
3569CAA51EC1918E000C41C0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/NohanaImagePicker.strings; sourceTree = "<group>"; };
3569CAA61EC1918E000C41C0 /* NohanaImagePicker.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = NohanaImagePicker.xcassets; sourceTree = "<group>"; };
3569CAA71EC1918E000C41C0 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/NohanaImagePicker.strings; sourceTree = "<group>"; };
F20257391C7343D20069B33A /* ImageName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageName.swift; sourceTree = "<group>"; };
F202573B1C7418920069B33A /* PickedAssetList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickedAssetList.swift; sourceTree = "<group>"; };
F208E5511CD7370B00FFC9F6 /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -85,7 +90,7 @@
F218D7DD1C6C3A5B001FCED1 /* AlbumCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlbumCell.swift; sourceTree = "<group>"; };
F23554251C69D19C00796DCA /* NohanaImagePicker.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = NohanaImagePicker.storyboard; sourceTree = "<group>"; };
F23554271C69D5DB00796DCA /* NohanaImagePickerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NohanaImagePickerController.swift; sourceTree = "<group>"; };
F237249A1C6DCF96005D1E8A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
F237249A1C6DCF96005D1E8A /* NohanaImagePicker.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = NohanaImagePicker.xcassets; sourceTree = "<group>"; };
F23CC89D1CB745C800BCE443 /* ActivityIndicatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActivityIndicatable.swift; sourceTree = "<group>"; };
F24EB68F1C68AEED0002EC86 /* AlbumListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlbumListViewController.swift; sourceTree = "<group>"; };
F25C10C11C8ED9BF007453C3 /* MomentViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MomentViewController.swift; sourceTree = "<group>"; };
@ -132,9 +137,19 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
3569CAA31EC1918E000C41C0 /* Resources */ = {
isa = PBXGroup;
children = (
3569CAA41EC1918E000C41C0 /* NohanaImagePicker.strings */,
3569CAA61EC1918E000C41C0 /* NohanaImagePicker.xcassets */,
);
path = Resources;
sourceTree = "<group>";
};
F208E5521CD7370B00FFC9F6 /* Demo */ = {
isa = PBXGroup;
children = (
3569CAA31EC1918E000C41C0 /* Resources */,
F208E5531CD7370B00FFC9F6 /* AppDelegate.swift */,
F208E5681CD738CD00FFC9F6 /* DemoListViewController.swift */,
F208E5571CD7370B00FFC9F6 /* Main.storyboard */,
@ -163,7 +178,7 @@
children = (
F23554251C69D19C00796DCA /* NohanaImagePicker.storyboard */,
F27029CD1C71C43A001647AB /* NohanaImagePicker.strings */,
F237249A1C6DCF96005D1E8A /* Images.xcassets */,
F237249A1C6DCF96005D1E8A /* NohanaImagePicker.xcassets */,
);
name = Resources;
sourceTree = "<group>";
@ -346,8 +361,10 @@
buildActionMask = 2147483647;
files = (
F208E55E1CD7370B00FFC9F6 /* LaunchScreen.storyboard in Resources */,
3569CAA91EC1918E000C41C0 /* NohanaImagePicker.xcassets in Resources */,
F208E55B1CD7370B00FFC9F6 /* Assets.xcassets in Resources */,
F208E5591CD7370B00FFC9F6 /* Main.storyboard in Resources */,
3569CAA81EC1918E000C41C0 /* NohanaImagePicker.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -357,7 +374,7 @@
files = (
F23554261C69D19C00796DCA /* NohanaImagePicker.storyboard in Resources */,
F27029CB1C71C43A001647AB /* NohanaImagePicker.strings in Resources */,
F237249B1C6DCF96005D1E8A /* Images.xcassets in Resources */,
F237249B1C6DCF96005D1E8A /* NohanaImagePicker.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -417,6 +434,15 @@
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
3569CAA41EC1918E000C41C0 /* NohanaImagePicker.strings */ = {
isa = PBXVariantGroup;
children = (
3569CAA51EC1918E000C41C0 /* en */,
3569CAA71EC1918E000C41C0 /* ja */,
);
name = NohanaImagePicker.strings;
sourceTree = "<group>";
};
F208E5571CD7370B00FFC9F6 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (

View File

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "btn_select_l@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "btn_select_l@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "btn_select_m@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "btn_select_m@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "btn_selected_l@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "btn_selected_l@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "btn_selected_m@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "btn_selected_m@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "icon_photosize_alert_s@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "icon_photosize_alert_s@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "icon_photosize_low_s@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "icon_photosize_low_s@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -49,7 +49,7 @@ open class NohanaImagePickerController: UIViewController {
open var canPickAsset = { (asset:Asset) -> Bool in
return true
}
lazy var assetBundle:Bundle = {
open lazy var assetBundle:Bundle = {
let bundle = Bundle(for: type(of: self))
if let path = bundle.path(forResource: "NohanaImagePicker", ofType: "bundle") {
return Bundle(path: path)!
@ -99,7 +99,7 @@ open class NohanaImagePickerController: UIViewController {
super.viewDidLoad()
// show albumListViewController
let storyboard = UIStoryboard(name: "NohanaImagePicker", bundle: assetBundle)
let storyboard = UIStoryboard(name: "NohanaImagePicker", bundle: Bundle(for: type(of: self)))
let viewControllerId = enableExpandingPhotoAnimation ? "EnableAnimationNavigationController" : "DisableAnimationNavigationController"
guard let navigationController = storyboard.instantiateViewController(withIdentifier: viewControllerId) as? UINavigationController else {
fatalError("navigationController init failed.")