Commit bd508a8739bca8ee3cc827f94f00b015c858b82c
1 parent
4a618b31
提交建仓部分
Showing
3 changed files
with
284 additions
and
12 deletions
CNLiveICloudPicker.podspec
| @@ -15,9 +15,9 @@ Pod::Spec.new do |s| | @@ -15,9 +15,9 @@ Pod::Spec.new do |s| | ||
| 15 | # summary should be tweet-length, and the description more in depth. | 15 | # summary should be tweet-length, and the description more in depth. |
| 16 | # | 16 | # |
| 17 | 17 | ||
| 18 | - s.name = "CNLiveICloudPicker" | ||
| 19 | - s.version = "0.0.1" | ||
| 20 | - s.summary = "A short description of CNLiveICloudPicker." | 18 | + s.name = "CNLiveICloudPicker" # 项目名称 |
| 19 | + s.version = "0.0.1" # 版本号 与 你仓库的 标签号 对应 | ||
| 20 | + s.summary = "iCloud选择器" # 项目简介 | ||
| 21 | 21 | ||
| 22 | # This description is used to generate tags and improve search results. | 22 | # This description is used to generate tags and improve search results. |
| 23 | # * Think: What does it do? Why did you write it? What is the focus? | 23 | # * Think: What does it do? Why did you write it? What is the focus? |
| @@ -25,9 +25,15 @@ Pod::Spec.new do |s| | @@ -25,9 +25,15 @@ Pod::Spec.new do |s| | ||
| 25 | # * Write the description between the DESC delimiters below. | 25 | # * Write the description between the DESC delimiters below. |
| 26 | # * Finally, don't worry about the indent, CocoaPods strips it! | 26 | # * Finally, don't worry about the indent, CocoaPods strips it! |
| 27 | s.description = <<-DESC | 27 | s.description = <<-DESC |
| 28 | + 用于iCloud管理库: | ||
| 29 | + 1.文件管理 | ||
| 30 | + 2.iCloud验证 | ||
| 31 | + 3.iCloud文件下载到本地 | ||
| 32 | + 4.TODO:iCloud写入 | ||
| 33 | + | ||
| 28 | DESC | 34 | DESC |
| 29 | 35 | ||
| 30 | - s.homepage = "http://EXAMPLE/CNLiveICloudPicker" | 36 | + s.homepage = "http://bj.gitlab.cnlive.com/ios-team/CNLiveICloudPicker" # 仓库的主页 |
| 31 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" | 37 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" |
| 32 | 38 | ||
| 33 | 39 | ||
| @@ -38,7 +44,7 @@ Pod::Spec.new do |s| | @@ -38,7 +44,7 @@ Pod::Spec.new do |s| | ||
| 38 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. | 44 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. |
| 39 | # | 45 | # |
| 40 | 46 | ||
| 41 | - s.license = "MIT (example)" | 47 | + s.license = "MIT" |
| 42 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } | 48 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } |
| 43 | 49 | ||
| 44 | 50 | ||
| @@ -52,7 +58,7 @@ Pod::Spec.new do |s| | @@ -52,7 +58,7 @@ Pod::Spec.new do |s| | ||
| 52 | # profile URL. | 58 | # profile URL. |
| 53 | # | 59 | # |
| 54 | 60 | ||
| 55 | - s.author = { "梁星国" => "jyyjkt@qq.com" } | 61 | + s.author = { "梁星国" => "liangxinguo@cnlive.com" } |
| 56 | # Or just: s.author = "梁星国" | 62 | # Or just: s.author = "梁星国" |
| 57 | # s.authors = { "梁星国" => "jyyjkt@qq.com" } | 63 | # s.authors = { "梁星国" => "jyyjkt@qq.com" } |
| 58 | # s.social_media_url = "http://twitter.com/梁星国" | 64 | # s.social_media_url = "http://twitter.com/梁星国" |
| @@ -64,7 +70,7 @@ Pod::Spec.new do |s| | @@ -64,7 +70,7 @@ Pod::Spec.new do |s| | ||
| 64 | # | 70 | # |
| 65 | 71 | ||
| 66 | # s.platform = :ios | 72 | # s.platform = :ios |
| 67 | - # s.platform = :ios, "5.0" | 73 | + s.platform = :ios, "9.0" |
| 68 | 74 | ||
| 69 | # When using multiple platforms | 75 | # When using multiple platforms |
| 70 | # s.ios.deployment_target = "5.0" | 76 | # s.ios.deployment_target = "5.0" |
| @@ -79,7 +85,7 @@ Pod::Spec.new do |s| | @@ -79,7 +85,7 @@ Pod::Spec.new do |s| | ||
| 79 | # Supports git, hg, bzr, svn and HTTP. | 85 | # Supports git, hg, bzr, svn and HTTP. |
| 80 | # | 86 | # |
| 81 | 87 | ||
| 82 | - s.source = { :git => "http://EXAMPLE/CNLiveICloudPicker.git", :tag => "#{s.version}" } | 88 | + s.source = { :git => "http://bj.gitlab.cnlive.com/ios-team/CNLiveICloudPicker.git", :tag => "#{s.version}" } |
| 83 | 89 | ||
| 84 | 90 | ||
| 85 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # | 91 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # |
| @@ -90,8 +96,8 @@ Pod::Spec.new do |s| | @@ -90,8 +96,8 @@ Pod::Spec.new do |s| | ||
| 90 | # Not including the public_header_files will make all headers public. | 96 | # Not including the public_header_files will make all headers public. |
| 91 | # | 97 | # |
| 92 | 98 | ||
| 93 | - s.source_files = "Classes", "Classes/**/*.{h,m}" | ||
| 94 | - s.exclude_files = "Classes/Exclude" | 99 | + s.source_files = "CNLiveICloudPicker/*.{h,m}" # 文件位置 |
| 100 | + #s.exclude_files = "Classes/Exclude" | ||
| 95 | 101 | ||
| 96 | # s.public_header_files = "Classes/**/*.h" | 102 | # s.public_header_files = "Classes/**/*.h" |
| 97 | 103 | ||
| @@ -117,7 +123,7 @@ Pod::Spec.new do |s| | @@ -117,7 +123,7 @@ Pod::Spec.new do |s| | ||
| 117 | # | 123 | # |
| 118 | 124 | ||
| 119 | # s.framework = "SomeFramework" | 125 | # s.framework = "SomeFramework" |
| 120 | - # s.frameworks = "SomeFramework", "AnotherFramework" | 126 | + s.frameworks = "UIKit", "Foundation" # |
| 121 | 127 | ||
| 122 | # s.library = "iconv" | 128 | # s.library = "iconv" |
| 123 | # s.libraries = "iconv", "xml2" | 129 | # s.libraries = "iconv", "xml2" |
| @@ -129,7 +135,7 @@ Pod::Spec.new do |s| | @@ -129,7 +135,7 @@ Pod::Spec.new do |s| | ||
| 129 | # where they will only apply to your library. If you depend on other Podspecs | 135 | # where they will only apply to your library. If you depend on other Podspecs |
| 130 | # you can include multiple dependencies to ensure it works. | 136 | # you can include multiple dependencies to ensure it works. |
| 131 | 137 | ||
| 132 | - # s.requires_arc = true | 138 | + s.requires_arc = true |
| 133 | 139 | ||
| 134 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } | 140 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } |
| 135 | # s.dependency "JSONKit", "~> 1.4" | 141 | # s.dependency "JSONKit", "~> 1.4" |
CNLiveICloudPicker/UIAlertController+Blocks.h
0 → 100755
| 1 | +// | ||
| 2 | +// UIAlertController+Blocks.h | ||
| 3 | +// UIAlertControllerBlocks | ||
| 4 | +// | ||
| 5 | +// Created by Ryan Maxwell on 11/09/14. | ||
| 6 | +// | ||
| 7 | +// The MIT License (MIT) | ||
| 8 | +// | ||
| 9 | +// Copyright (c) 2014 Ryan Maxwell | ||
| 10 | +// | ||
| 11 | +// Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 12 | +// this software and associated documentation files (the "Software"), to deal in | ||
| 13 | +// the Software without restriction, including without limitation the rights to | ||
| 14 | +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| 15 | +// the Software, and to permit persons to whom the Software is furnished to do so, | ||
| 16 | +// subject to the following conditions: | ||
| 17 | +// | ||
| 18 | +// The above copyright notice and this permission notice shall be included in all | ||
| 19 | +// copies or substantial portions of the Software. | ||
| 20 | +// | ||
| 21 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 22 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| 23 | +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| 24 | +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| 25 | +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 26 | +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 27 | +// | ||
| 28 | + | ||
| 29 | +#import <UIKit/UIKit.h> | ||
| 30 | + | ||
| 31 | +#if TARGET_OS_IOS | ||
| 32 | +typedef void (^UIAlertControllerPopoverPresentationControllerBlock) (UIPopoverPresentationController * __nonnull popover); | ||
| 33 | +#endif | ||
| 34 | +typedef void (^UIAlertControllerCompletionBlock) (UIAlertController * __nonnull controller, UIAlertAction * __nonnull action, NSInteger buttonIndex); | ||
| 35 | + | ||
| 36 | +@interface UIAlertController (Blocks) | ||
| 37 | + | ||
| 38 | ++ (nonnull instancetype)showInViewController:(nonnull UIViewController *)viewController | ||
| 39 | + withTitle:(nullable NSString *)title | ||
| 40 | + message:(nullable NSString *)message | ||
| 41 | + preferredStyle:(UIAlertControllerStyle)preferredStyle | ||
| 42 | + cancelButtonTitle:(nullable NSString *)cancelButtonTitle | ||
| 43 | + destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle | ||
| 44 | + otherButtonTitles:(nullable NSArray *)otherButtonTitles | ||
| 45 | +#if TARGET_OS_IOS | ||
| 46 | + popoverPresentationControllerBlock:(nullable UIAlertControllerPopoverPresentationControllerBlock)popoverPresentationControllerBlock | ||
| 47 | +#endif | ||
| 48 | + tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock; | ||
| 49 | + | ||
| 50 | ++ (nonnull instancetype)showAlertInViewController:(nonnull UIViewController *)viewController | ||
| 51 | + withTitle:(nullable NSString *)title | ||
| 52 | + message:(nullable NSString *)message | ||
| 53 | + cancelButtonTitle:(nullable NSString *)cancelButtonTitle | ||
| 54 | + destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle | ||
| 55 | + otherButtonTitles:(nullable NSArray *)otherButtonTitles | ||
| 56 | + tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock; | ||
| 57 | + | ||
| 58 | + | ||
| 59 | ++ (nonnull instancetype)showActionSheetInViewController:(nonnull UIViewController *)viewController | ||
| 60 | + withTitle:(nullable NSString *)title | ||
| 61 | + message:(nullable NSString *)message | ||
| 62 | + cancelButtonTitle:(nullable NSString *)cancelButtonTitle | ||
| 63 | + destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle | ||
| 64 | + otherButtonTitles:(nullable NSArray *)otherButtonTitles | ||
| 65 | +#if TARGET_OS_IOS | ||
| 66 | + popoverPresentationControllerBlock:(nullable UIAlertControllerPopoverPresentationControllerBlock)popoverPresentationControllerBlock | ||
| 67 | +#endif | ||
| 68 | + tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock; | ||
| 69 | + | ||
| 70 | + | ||
| 71 | +@property (readonly, nonatomic) BOOL visible; | ||
| 72 | +@property (readonly, nonatomic) NSInteger cancelButtonIndex; | ||
| 73 | +@property (readonly, nonatomic) NSInteger firstOtherButtonIndex; | ||
| 74 | +@property (readonly, nonatomic) NSInteger destructiveButtonIndex; | ||
| 75 | + | ||
| 76 | +@end |
CNLiveICloudPicker/UIAlertController+Blocks.m
0 → 100755
| 1 | +// | ||
| 2 | +// UIAlertController+Blocks.m | ||
| 3 | +// UIAlertControllerBlocks | ||
| 4 | +// | ||
| 5 | +// Created by Ryan Maxwell on 11/09/14. | ||
| 6 | +// | ||
| 7 | +// The MIT License (MIT) | ||
| 8 | +// | ||
| 9 | +// Copyright (c) 2014 Ryan Maxwell | ||
| 10 | +// | ||
| 11 | +// Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 12 | +// this software and associated documentation files (the "Software"), to deal in | ||
| 13 | +// the Software without restriction, including without limitation the rights to | ||
| 14 | +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| 15 | +// the Software, and to permit persons to whom the Software is furnished to do so, | ||
| 16 | +// subject to the following conditions: | ||
| 17 | +// | ||
| 18 | +// The above copyright notice and this permission notice shall be included in all | ||
| 19 | +// copies or substantial portions of the Software. | ||
| 20 | +// | ||
| 21 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 22 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| 23 | +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| 24 | +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| 25 | +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 26 | +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 27 | +// | ||
| 28 | + | ||
| 29 | +#import "UIAlertController+Blocks.h" | ||
| 30 | + | ||
| 31 | +static NSInteger const UIAlertControllerBlocksCancelButtonIndex = 0; | ||
| 32 | +static NSInteger const UIAlertControllerBlocksDestructiveButtonIndex = 1; | ||
| 33 | +static NSInteger const UIAlertControllerBlocksFirstOtherButtonIndex = 2; | ||
| 34 | + | ||
| 35 | +@interface UIViewController (UACB_Topmost) | ||
| 36 | + | ||
| 37 | +- (UIViewController *)uacb_topmost; | ||
| 38 | + | ||
| 39 | +@end | ||
| 40 | + | ||
| 41 | +@implementation UIAlertController (Blocks) | ||
| 42 | + | ||
| 43 | ++ (instancetype)showInViewController:(UIViewController *)viewController | ||
| 44 | + withTitle:(NSString *)title | ||
| 45 | + message:(NSString *)message | ||
| 46 | + preferredStyle:(UIAlertControllerStyle)preferredStyle | ||
| 47 | + cancelButtonTitle:(NSString *)cancelButtonTitle | ||
| 48 | + destructiveButtonTitle:(NSString *)destructiveButtonTitle | ||
| 49 | + otherButtonTitles:(NSArray *)otherButtonTitles | ||
| 50 | +#if TARGET_OS_IOS | ||
| 51 | + popoverPresentationControllerBlock:(void(^)(UIPopoverPresentationController *popover))popoverPresentationControllerBlock | ||
| 52 | +#endif | ||
| 53 | + tapBlock:(UIAlertControllerCompletionBlock)tapBlock | ||
| 54 | +{ | ||
| 55 | + UIAlertController *strongController = [self alertControllerWithTitle:title | ||
| 56 | + message:message | ||
| 57 | + preferredStyle:preferredStyle]; | ||
| 58 | + | ||
| 59 | + __weak UIAlertController *controller = strongController; | ||
| 60 | + | ||
| 61 | + if (cancelButtonTitle) { | ||
| 62 | + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle | ||
| 63 | + style:UIAlertActionStyleCancel | ||
| 64 | + handler:^(UIAlertAction *action){ | ||
| 65 | + if (tapBlock) { | ||
| 66 | + tapBlock(controller, action, UIAlertControllerBlocksCancelButtonIndex); | ||
| 67 | + } | ||
| 68 | + }]; | ||
| 69 | + [controller addAction:cancelAction]; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + if (destructiveButtonTitle) { | ||
| 73 | + UIAlertAction *destructiveAction = [UIAlertAction actionWithTitle:destructiveButtonTitle | ||
| 74 | + style:UIAlertActionStyleDestructive | ||
| 75 | + handler:^(UIAlertAction *action){ | ||
| 76 | + if (tapBlock) { | ||
| 77 | + tapBlock(controller, action, UIAlertControllerBlocksDestructiveButtonIndex); | ||
| 78 | + } | ||
| 79 | + }]; | ||
| 80 | + [controller addAction:destructiveAction]; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + for (NSUInteger i = 0; i < otherButtonTitles.count; i++) { | ||
| 84 | + NSString *otherButtonTitle = otherButtonTitles[i]; | ||
| 85 | + | ||
| 86 | + UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle | ||
| 87 | + style:UIAlertActionStyleDefault | ||
| 88 | + handler:^(UIAlertAction *action){ | ||
| 89 | + if (tapBlock) { | ||
| 90 | + tapBlock(controller, action, UIAlertControllerBlocksFirstOtherButtonIndex + i); | ||
| 91 | + } | ||
| 92 | + }]; | ||
| 93 | + [controller addAction:otherAction]; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | +#if TARGET_OS_IOS | ||
| 97 | + if (popoverPresentationControllerBlock) { | ||
| 98 | + popoverPresentationControllerBlock(controller.popoverPresentationController); | ||
| 99 | + } | ||
| 100 | +#endif | ||
| 101 | + | ||
| 102 | + [viewController.uacb_topmost presentViewController:controller animated:YES completion:nil]; | ||
| 103 | + | ||
| 104 | + return controller; | ||
| 105 | +} | ||
| 106 | + | ||
| 107 | ++ (instancetype)showAlertInViewController:(UIViewController *)viewController | ||
| 108 | + withTitle:(NSString *)title | ||
| 109 | + message:(NSString *)message | ||
| 110 | + cancelButtonTitle:(NSString *)cancelButtonTitle | ||
| 111 | + destructiveButtonTitle:(NSString *)destructiveButtonTitle | ||
| 112 | + otherButtonTitles:(NSArray *)otherButtonTitles | ||
| 113 | + tapBlock:(UIAlertControllerCompletionBlock)tapBlock | ||
| 114 | +{ | ||
| 115 | + return [self showInViewController:viewController | ||
| 116 | + withTitle:title | ||
| 117 | + message:message | ||
| 118 | + preferredStyle:UIAlertControllerStyleAlert | ||
| 119 | + cancelButtonTitle:cancelButtonTitle | ||
| 120 | + destructiveButtonTitle:destructiveButtonTitle | ||
| 121 | + otherButtonTitles:otherButtonTitles | ||
| 122 | +#if TARGET_OS_IOS | ||
| 123 | + popoverPresentationControllerBlock:nil | ||
| 124 | +#endif | ||
| 125 | + tapBlock:tapBlock]; | ||
| 126 | +} | ||
| 127 | + | ||
| 128 | ++ (instancetype)showActionSheetInViewController:(UIViewController *)viewController | ||
| 129 | + withTitle:(NSString *)title | ||
| 130 | + message:(NSString *)message | ||
| 131 | + cancelButtonTitle:(NSString *)cancelButtonTitle | ||
| 132 | + destructiveButtonTitle:(NSString *)destructiveButtonTitle | ||
| 133 | + otherButtonTitles:(NSArray *)otherButtonTitles | ||
| 134 | +#if TARGET_OS_IOS | ||
| 135 | + popoverPresentationControllerBlock:(void(^)(UIPopoverPresentationController *popover))popoverPresentationControllerBlock | ||
| 136 | +#endif | ||
| 137 | + tapBlock:(UIAlertControllerCompletionBlock)tapBlock | ||
| 138 | +{ | ||
| 139 | + return [self showInViewController:viewController | ||
| 140 | + withTitle:title | ||
| 141 | + message:message | ||
| 142 | + preferredStyle:UIAlertControllerStyleActionSheet | ||
| 143 | + cancelButtonTitle:cancelButtonTitle | ||
| 144 | + destructiveButtonTitle:destructiveButtonTitle | ||
| 145 | + otherButtonTitles:otherButtonTitles | ||
| 146 | +#if TARGET_OS_IOS | ||
| 147 | + popoverPresentationControllerBlock:popoverPresentationControllerBlock | ||
| 148 | +#endif | ||
| 149 | + tapBlock:tapBlock]; | ||
| 150 | +} | ||
| 151 | + | ||
| 152 | +#pragma mark - | ||
| 153 | + | ||
| 154 | +- (BOOL)visible | ||
| 155 | +{ | ||
| 156 | + return self.view.superview != nil; | ||
| 157 | +} | ||
| 158 | + | ||
| 159 | +- (NSInteger)cancelButtonIndex | ||
| 160 | +{ | ||
| 161 | + return UIAlertControllerBlocksCancelButtonIndex; | ||
| 162 | +} | ||
| 163 | + | ||
| 164 | +- (NSInteger)firstOtherButtonIndex | ||
| 165 | +{ | ||
| 166 | + return UIAlertControllerBlocksFirstOtherButtonIndex; | ||
| 167 | +} | ||
| 168 | + | ||
| 169 | +- (NSInteger)destructiveButtonIndex | ||
| 170 | +{ | ||
| 171 | + return UIAlertControllerBlocksDestructiveButtonIndex; | ||
| 172 | +} | ||
| 173 | + | ||
| 174 | +@end | ||
| 175 | + | ||
| 176 | +@implementation UIViewController (UACB_Topmost) | ||
| 177 | + | ||
| 178 | +- (UIViewController *)uacb_topmost | ||
| 179 | +{ | ||
| 180 | + UIViewController *topmost = self; | ||
| 181 | + | ||
| 182 | + UIViewController *above; | ||
| 183 | + while ((above = topmost.presentedViewController)) { | ||
| 184 | + topmost = above; | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + return topmost; | ||
| 188 | +} | ||
| 189 | + | ||
| 190 | +@end |