├── .gitignore ├── .travis.yml ├── Example ├── PickerController.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── PickerController-Example.xcscheme ├── PickerController.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── PickerController │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Info.plist │ ├── ViewController.swift │ └── chinese_regionalism.json ├── Podfile └── Podfile.lock ├── LICENSE ├── PickerController.podspec ├── PickerController.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── PickerController.xcscheme ├── PickerController └── Classes │ ├── Info.plist │ ├── PickerControl_Base.swift │ ├── PickerControl_Correlation.swift │ ├── PickerControl_Date.swift │ ├── PickerControl_Group.swift │ ├── PickerController.h │ ├── PickerController_Base.swift │ ├── PickerController_Correlation.swift │ ├── PickerController_Date.swift │ ├── PickerController_Group.swift │ ├── Tree+Height.swift │ ├── Tree.swift │ └── UIViewController+ShowPicker.swift ├── README.md ├── ScreenShot ├── PickerController.gif ├── Simulator Screen Shot 25 Nov 2016, 4.54.07 PM.png └── Simulator Screen Shot 25 Nov 2016, 4.54.07 PM_result1.jpg └── _Pods.xcodeproj /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # Bundler 23 | .bundle 24 | 25 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 26 | Carthage/Checkouts 27 | 28 | Carthage/Build 29 | 30 | # We recommend against adding the Pods directory to your .gitignore. However 31 | # you should judge for yourself, the pros and cons are mentioned at: 32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 33 | # 34 | # Note: if you ignore the Pods directory, make sure to uncomment 35 | # `pod install` in .travis.yml 36 | # 37 | Pods/ 38 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * https://www.objc.io/issues/6-build-tools/travis-ci/ 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode7.3 6 | language: objective-c 7 | # cache: cocoapods 8 | # podfile: Example/Podfile 9 | # before_install: 10 | # - gem install cocoapods # Since Travis is not always on latest version 11 | # - pod install --project-directory=Example 12 | script: 13 | - set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/PickerController.xcworkspace -scheme PickerController-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | - pod lib lint 15 | -------------------------------------------------------------------------------- /Example/PickerController.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 267434A92C64759828B2774C /* Pods_PickerController_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C771C0943D63A9D5EFA4D9F6 /* Pods_PickerController_Example.framework */; }; 11 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 12 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; 13 | D8180B2D21B6869B009D93E7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D8180B2C21B6869B009D93E7 /* Assets.xcassets */; }; 14 | D8180B3021B686DB009D93E7 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D8180B2E21B686DB009D93E7 /* LaunchScreen.storyboard */; }; 15 | D88C4A2121B7C80200136279 /* chinese_regionalism.json in Resources */ = {isa = PBXBuildFile; fileRef = D88C4A2021B7C80200136279 /* chinese_regionalism.json */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 4D16F41DA6FA652E9D8B16AA /* PickerController.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = PickerController.podspec; path = ../PickerController.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 20 | 5C056289E8F87DAD65A95A18 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 21 | 607FACD01AFB9204008FA782 /* PickerController_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PickerController_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 23 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 24 | 607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 25 | 72730C81CA48F1C30B38B519 /* Pods-PickerController_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PickerController_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-PickerController_Example/Pods-PickerController_Example.release.xcconfig"; sourceTree = ""; }; 26 | 8B45D24A1D4BCA784EC1DFA9 /* Pods_PickerController_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PickerController_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | C771C0943D63A9D5EFA4D9F6 /* Pods_PickerController_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PickerController_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | D8180B2C21B6869B009D93E7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29 | D8180B2F21B686DB009D93E7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 30 | D88C4A2021B7C80200136279 /* chinese_regionalism.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = chinese_regionalism.json; sourceTree = ""; }; 31 | E66E8B0CD1694828EE0EDDEC /* Pods-PickerController_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PickerController_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PickerController_Example/Pods-PickerController_Example.debug.xcconfig"; sourceTree = ""; }; 32 | F3333DACA1515B44DA9731B6 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | 607FACCD1AFB9204008FA782 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | 267434A92C64759828B2774C /* Pods_PickerController_Example.framework in Frameworks */, 41 | ); 42 | runOnlyForDeploymentPostprocessing = 0; 43 | }; 44 | /* End PBXFrameworksBuildPhase section */ 45 | 46 | /* Begin PBXGroup section */ 47 | 03251EA188C7547A2C8C6006 /* Frameworks */ = { 48 | isa = PBXGroup; 49 | children = ( 50 | C771C0943D63A9D5EFA4D9F6 /* Pods_PickerController_Example.framework */, 51 | 8B45D24A1D4BCA784EC1DFA9 /* Pods_PickerController_Tests.framework */, 52 | ); 53 | name = Frameworks; 54 | sourceTree = ""; 55 | }; 56 | 1D6A8CCE3A60A17FF027B9B4 /* Pods */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | E66E8B0CD1694828EE0EDDEC /* Pods-PickerController_Example.debug.xcconfig */, 60 | 72730C81CA48F1C30B38B519 /* Pods-PickerController_Example.release.xcconfig */, 61 | ); 62 | name = Pods; 63 | sourceTree = ""; 64 | }; 65 | 607FACC71AFB9204008FA782 = { 66 | isa = PBXGroup; 67 | children = ( 68 | 607FACF51AFB993E008FA782 /* Podspec Metadata */, 69 | 607FACD21AFB9204008FA782 /* Example for PickerController */, 70 | 607FACD11AFB9204008FA782 /* Products */, 71 | 1D6A8CCE3A60A17FF027B9B4 /* Pods */, 72 | 03251EA188C7547A2C8C6006 /* Frameworks */, 73 | ); 74 | sourceTree = ""; 75 | }; 76 | 607FACD11AFB9204008FA782 /* Products */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 607FACD01AFB9204008FA782 /* PickerController_Example.app */, 80 | ); 81 | name = Products; 82 | sourceTree = ""; 83 | }; 84 | 607FACD21AFB9204008FA782 /* Example for PickerController */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */, 88 | 607FACD71AFB9204008FA782 /* ViewController.swift */, 89 | D8180B2C21B6869B009D93E7 /* Assets.xcassets */, 90 | D8180B2E21B686DB009D93E7 /* LaunchScreen.storyboard */, 91 | D88C4A2021B7C80200136279 /* chinese_regionalism.json */, 92 | 607FACD31AFB9204008FA782 /* Supporting Files */, 93 | ); 94 | name = "Example for PickerController"; 95 | path = PickerController; 96 | sourceTree = ""; 97 | }; 98 | 607FACD31AFB9204008FA782 /* Supporting Files */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 607FACD41AFB9204008FA782 /* Info.plist */, 102 | ); 103 | name = "Supporting Files"; 104 | sourceTree = ""; 105 | }; 106 | 607FACF51AFB993E008FA782 /* Podspec Metadata */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 4D16F41DA6FA652E9D8B16AA /* PickerController.podspec */, 110 | F3333DACA1515B44DA9731B6 /* README.md */, 111 | 5C056289E8F87DAD65A95A18 /* LICENSE */, 112 | ); 113 | name = "Podspec Metadata"; 114 | sourceTree = ""; 115 | }; 116 | /* End PBXGroup section */ 117 | 118 | /* Begin PBXNativeTarget section */ 119 | 607FACCF1AFB9204008FA782 /* PickerController_Example */ = { 120 | isa = PBXNativeTarget; 121 | buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "PickerController_Example" */; 122 | buildPhases = ( 123 | 488F43BB79B7ED75C0CE358D /* [CP] Check Pods Manifest.lock */, 124 | 607FACCC1AFB9204008FA782 /* Sources */, 125 | 607FACCD1AFB9204008FA782 /* Frameworks */, 126 | 607FACCE1AFB9204008FA782 /* Resources */, 127 | 3C5403C37AB31EB81E3EEADB /* [CP] Embed Pods Frameworks */, 128 | ); 129 | buildRules = ( 130 | ); 131 | dependencies = ( 132 | ); 133 | name = PickerController_Example; 134 | productName = PickerController; 135 | productReference = 607FACD01AFB9204008FA782 /* PickerController_Example.app */; 136 | productType = "com.apple.product-type.application"; 137 | }; 138 | /* End PBXNativeTarget section */ 139 | 140 | /* Begin PBXProject section */ 141 | 607FACC81AFB9204008FA782 /* Project object */ = { 142 | isa = PBXProject; 143 | attributes = { 144 | LastSwiftUpdateCheck = 0830; 145 | LastUpgradeCheck = 0830; 146 | ORGANIZATIONNAME = CocoaPods; 147 | TargetAttributes = { 148 | 607FACCF1AFB9204008FA782 = { 149 | CreatedOnToolsVersion = 6.3.1; 150 | LastSwiftMigration = 0900; 151 | }; 152 | }; 153 | }; 154 | buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "PickerController" */; 155 | compatibilityVersion = "Xcode 3.2"; 156 | developmentRegion = English; 157 | hasScannedForEncodings = 0; 158 | knownRegions = ( 159 | en, 160 | Base, 161 | ); 162 | mainGroup = 607FACC71AFB9204008FA782; 163 | productRefGroup = 607FACD11AFB9204008FA782 /* Products */; 164 | projectDirPath = ""; 165 | projectRoot = ""; 166 | targets = ( 167 | 607FACCF1AFB9204008FA782 /* PickerController_Example */, 168 | ); 169 | }; 170 | /* End PBXProject section */ 171 | 172 | /* Begin PBXResourcesBuildPhase section */ 173 | 607FACCE1AFB9204008FA782 /* Resources */ = { 174 | isa = PBXResourcesBuildPhase; 175 | buildActionMask = 2147483647; 176 | files = ( 177 | D8180B2D21B6869B009D93E7 /* Assets.xcassets in Resources */, 178 | D8180B3021B686DB009D93E7 /* LaunchScreen.storyboard in Resources */, 179 | D88C4A2121B7C80200136279 /* chinese_regionalism.json in Resources */, 180 | ); 181 | runOnlyForDeploymentPostprocessing = 0; 182 | }; 183 | /* End PBXResourcesBuildPhase section */ 184 | 185 | /* Begin PBXShellScriptBuildPhase section */ 186 | 3C5403C37AB31EB81E3EEADB /* [CP] Embed Pods Frameworks */ = { 187 | isa = PBXShellScriptBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | ); 191 | inputFileListPaths = ( 192 | ); 193 | inputPaths = ( 194 | "${SRCROOT}/Pods/Target Support Files/Pods-PickerController_Example/Pods-PickerController_Example-frameworks.sh", 195 | "${BUILT_PRODUCTS_DIR}/PickerController/PickerController.framework", 196 | ); 197 | name = "[CP] Embed Pods Frameworks"; 198 | outputFileListPaths = ( 199 | ); 200 | outputPaths = ( 201 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PickerController.framework", 202 | ); 203 | runOnlyForDeploymentPostprocessing = 0; 204 | shellPath = /bin/sh; 205 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-PickerController_Example/Pods-PickerController_Example-frameworks.sh\"\n"; 206 | showEnvVarsInLog = 0; 207 | }; 208 | 488F43BB79B7ED75C0CE358D /* [CP] Check Pods Manifest.lock */ = { 209 | isa = PBXShellScriptBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | ); 213 | inputFileListPaths = ( 214 | ); 215 | inputPaths = ( 216 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 217 | "${PODS_ROOT}/Manifest.lock", 218 | ); 219 | name = "[CP] Check Pods Manifest.lock"; 220 | outputFileListPaths = ( 221 | ); 222 | outputPaths = ( 223 | "$(DERIVED_FILE_DIR)/Pods-PickerController_Example-checkManifestLockResult.txt", 224 | ); 225 | runOnlyForDeploymentPostprocessing = 0; 226 | shellPath = /bin/sh; 227 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 228 | showEnvVarsInLog = 0; 229 | }; 230 | /* End PBXShellScriptBuildPhase section */ 231 | 232 | /* Begin PBXSourcesBuildPhase section */ 233 | 607FACCC1AFB9204008FA782 /* Sources */ = { 234 | isa = PBXSourcesBuildPhase; 235 | buildActionMask = 2147483647; 236 | files = ( 237 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */, 238 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | /* End PBXSourcesBuildPhase section */ 243 | 244 | /* Begin PBXVariantGroup section */ 245 | D8180B2E21B686DB009D93E7 /* LaunchScreen.storyboard */ = { 246 | isa = PBXVariantGroup; 247 | children = ( 248 | D8180B2F21B686DB009D93E7 /* Base */, 249 | ); 250 | name = LaunchScreen.storyboard; 251 | sourceTree = ""; 252 | }; 253 | /* End PBXVariantGroup section */ 254 | 255 | /* Begin XCBuildConfiguration section */ 256 | 607FACED1AFB9204008FA782 /* Debug */ = { 257 | isa = XCBuildConfiguration; 258 | buildSettings = { 259 | ALWAYS_SEARCH_USER_PATHS = NO; 260 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 261 | CLANG_CXX_LIBRARY = "libc++"; 262 | CLANG_ENABLE_MODULES = YES; 263 | CLANG_ENABLE_OBJC_ARC = YES; 264 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 265 | CLANG_WARN_BOOL_CONVERSION = YES; 266 | CLANG_WARN_COMMA = YES; 267 | CLANG_WARN_CONSTANT_CONVERSION = YES; 268 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 269 | CLANG_WARN_EMPTY_BODY = YES; 270 | CLANG_WARN_ENUM_CONVERSION = YES; 271 | CLANG_WARN_INFINITE_RECURSION = YES; 272 | CLANG_WARN_INT_CONVERSION = YES; 273 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 274 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 275 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 276 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 277 | CLANG_WARN_STRICT_PROTOTYPES = YES; 278 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 279 | CLANG_WARN_UNREACHABLE_CODE = YES; 280 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 281 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 282 | COPY_PHASE_STRIP = NO; 283 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 284 | ENABLE_STRICT_OBJC_MSGSEND = YES; 285 | ENABLE_TESTABILITY = YES; 286 | GCC_C_LANGUAGE_STANDARD = gnu99; 287 | GCC_DYNAMIC_NO_PIC = NO; 288 | GCC_NO_COMMON_BLOCKS = YES; 289 | GCC_OPTIMIZATION_LEVEL = 0; 290 | GCC_PREPROCESSOR_DEFINITIONS = ( 291 | "DEBUG=1", 292 | "$(inherited)", 293 | ); 294 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 295 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 296 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 297 | GCC_WARN_UNDECLARED_SELECTOR = YES; 298 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 299 | GCC_WARN_UNUSED_FUNCTION = YES; 300 | GCC_WARN_UNUSED_VARIABLE = YES; 301 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 302 | MTL_ENABLE_DEBUG_INFO = YES; 303 | ONLY_ACTIVE_ARCH = YES; 304 | SDKROOT = iphoneos; 305 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 306 | }; 307 | name = Debug; 308 | }; 309 | 607FACEE1AFB9204008FA782 /* Release */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | ALWAYS_SEARCH_USER_PATHS = NO; 313 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 314 | CLANG_CXX_LIBRARY = "libc++"; 315 | CLANG_ENABLE_MODULES = YES; 316 | CLANG_ENABLE_OBJC_ARC = YES; 317 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 318 | CLANG_WARN_BOOL_CONVERSION = YES; 319 | CLANG_WARN_COMMA = YES; 320 | CLANG_WARN_CONSTANT_CONVERSION = YES; 321 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 322 | CLANG_WARN_EMPTY_BODY = YES; 323 | CLANG_WARN_ENUM_CONVERSION = YES; 324 | CLANG_WARN_INFINITE_RECURSION = YES; 325 | CLANG_WARN_INT_CONVERSION = YES; 326 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 327 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 328 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 329 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 330 | CLANG_WARN_STRICT_PROTOTYPES = YES; 331 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 332 | CLANG_WARN_UNREACHABLE_CODE = YES; 333 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 334 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 335 | COPY_PHASE_STRIP = NO; 336 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 337 | ENABLE_NS_ASSERTIONS = NO; 338 | ENABLE_STRICT_OBJC_MSGSEND = YES; 339 | GCC_C_LANGUAGE_STANDARD = gnu99; 340 | GCC_NO_COMMON_BLOCKS = YES; 341 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 342 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 343 | GCC_WARN_UNDECLARED_SELECTOR = YES; 344 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 345 | GCC_WARN_UNUSED_FUNCTION = YES; 346 | GCC_WARN_UNUSED_VARIABLE = YES; 347 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 348 | MTL_ENABLE_DEBUG_INFO = NO; 349 | SDKROOT = iphoneos; 350 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 351 | VALIDATE_PRODUCT = YES; 352 | }; 353 | name = Release; 354 | }; 355 | 607FACF01AFB9204008FA782 /* Debug */ = { 356 | isa = XCBuildConfiguration; 357 | baseConfigurationReference = E66E8B0CD1694828EE0EDDEC /* Pods-PickerController_Example.debug.xcconfig */; 358 | buildSettings = { 359 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 360 | INFOPLIST_FILE = PickerController/Info.plist; 361 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 362 | MODULE_NAME = ExampleApp; 363 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 364 | PRODUCT_NAME = "$(TARGET_NAME)"; 365 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 366 | SWIFT_VERSION = 4.0; 367 | }; 368 | name = Debug; 369 | }; 370 | 607FACF11AFB9204008FA782 /* Release */ = { 371 | isa = XCBuildConfiguration; 372 | baseConfigurationReference = 72730C81CA48F1C30B38B519 /* Pods-PickerController_Example.release.xcconfig */; 373 | buildSettings = { 374 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 375 | INFOPLIST_FILE = PickerController/Info.plist; 376 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 377 | MODULE_NAME = ExampleApp; 378 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 379 | PRODUCT_NAME = "$(TARGET_NAME)"; 380 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 381 | SWIFT_VERSION = 4.0; 382 | }; 383 | name = Release; 384 | }; 385 | /* End XCBuildConfiguration section */ 386 | 387 | /* Begin XCConfigurationList section */ 388 | 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "PickerController" */ = { 389 | isa = XCConfigurationList; 390 | buildConfigurations = ( 391 | 607FACED1AFB9204008FA782 /* Debug */, 392 | 607FACEE1AFB9204008FA782 /* Release */, 393 | ); 394 | defaultConfigurationIsVisible = 0; 395 | defaultConfigurationName = Release; 396 | }; 397 | 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "PickerController_Example" */ = { 398 | isa = XCConfigurationList; 399 | buildConfigurations = ( 400 | 607FACF01AFB9204008FA782 /* Debug */, 401 | 607FACF11AFB9204008FA782 /* Release */, 402 | ); 403 | defaultConfigurationIsVisible = 0; 404 | defaultConfigurationName = Release; 405 | }; 406 | /* End XCConfigurationList section */ 407 | }; 408 | rootObject = 607FACC81AFB9204008FA782 /* Project object */; 409 | } 410 | -------------------------------------------------------------------------------- /Example/PickerController.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/PickerController.xcodeproj/xcshareddata/xcschemes/PickerController-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 45 | 46 | 48 | 54 | 55 | 56 | 57 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 80 | 82 | 88 | 89 | 90 | 91 | 92 | 93 | 99 | 101 | 107 | 108 | 109 | 110 | 112 | 113 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /Example/PickerController.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/PickerController.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/PickerController/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CorrelationPicker-Example 4 | // 5 | // Created by 王继荣 on 29/10/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | 20 | window = UIWindow() 21 | window?.backgroundColor = UIColor.white 22 | window?.rootViewController = ViewController() 23 | window?.makeKeyAndVisible() 24 | 25 | return true 26 | } 27 | 28 | func applicationWillResignActive(_ application: UIApplication) { 29 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 30 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 31 | } 32 | 33 | func applicationDidEnterBackground(_ application: UIApplication) { 34 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 35 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 36 | } 37 | 38 | func applicationWillEnterForeground(_ application: UIApplication) { 39 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 40 | } 41 | 42 | func applicationDidBecomeActive(_ application: UIApplication) { 43 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 44 | } 45 | 46 | func applicationWillTerminate(_ application: UIApplication) { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /Example/PickerController/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Example/PickerController/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Example/PickerController/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Example/PickerController/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CorrelationPicker-Example 4 | // 5 | // Created by 王继荣 on 29/10/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import PickerController 11 | 12 | class ViewController: UIViewController { 13 | 14 | var button1 = UIButton(type: .system) 15 | var button2 = UIButton(type: .system) 16 | var button3 = UIButton(type: .system) 17 | var labelIndices = UILabel() 18 | var labelItems = UILabel() 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | 23 | view.backgroundColor = UIColor.white 24 | 25 | button1.translatesAutoresizingMaskIntoConstraints = false 26 | button1.setTitle("GroupPicker", for: .normal) 27 | button1.addTarget(self, action: #selector(onClicked_button1), for: .touchUpInside) 28 | view.addSubview(button1) 29 | view.addConstraint(NSLayoutConstraint(item: button1, attribute: .centerX, relatedBy: .equal, toItem: view, attribute: .centerX, multiplier: 1, constant: 0)) 30 | view.addConstraint(NSLayoutConstraint(item: button1, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1, constant: 100)) 31 | 32 | button2.translatesAutoresizingMaskIntoConstraints = false 33 | button2.setTitle("CorrelationPicker", for: .normal) 34 | button2.addTarget(self, action: #selector(onClicked_button2), for: .touchUpInside) 35 | view.addSubview(button2) 36 | view.addConstraint(NSLayoutConstraint(item: button2, attribute: .centerX, relatedBy: .equal, toItem: view, attribute: .centerX, multiplier: 1, constant: 0)) 37 | view.addConstraint(NSLayoutConstraint(item: button2, attribute: .top, relatedBy: .equal, toItem: button1, attribute: .bottom, multiplier: 1, constant: 30)) 38 | 39 | button3.translatesAutoresizingMaskIntoConstraints = false 40 | button3.setTitle("DatePicker", for: .normal) 41 | button3.addTarget(self, action: #selector(onClicked_button3), for: .touchUpInside) 42 | view.addSubview(button3) 43 | view.addConstraint(NSLayoutConstraint(item: button3, attribute: .centerX, relatedBy: .equal, toItem: view, attribute: .centerX, multiplier: 1, constant: 0)) 44 | view.addConstraint(NSLayoutConstraint(item: button3, attribute: .top, relatedBy: .equal, toItem: button2, attribute: .bottom, multiplier: 1, constant: 30)) 45 | 46 | labelIndices.translatesAutoresizingMaskIntoConstraints = false 47 | view.addSubview(labelIndices) 48 | view.addConstraint(NSLayoutConstraint(item: labelIndices, attribute: .centerX, relatedBy: .equal, toItem: view, attribute: .centerX, multiplier: 1, constant: 0)) 49 | view.addConstraint(NSLayoutConstraint(item: labelIndices, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1, constant: -30)) 50 | 51 | labelItems.translatesAutoresizingMaskIntoConstraints = false 52 | view.addSubview(labelItems) 53 | view.addConstraint(NSLayoutConstraint(item: labelItems, attribute: .centerX, relatedBy: .equal, toItem: view, attribute: .centerX, multiplier: 1, constant: 0)) 54 | view.addConstraint(NSLayoutConstraint(item: labelItems, attribute: .bottom, relatedBy: .equal, toItem: labelIndices, attribute: .top, multiplier: 1, constant: -30)) 55 | } 56 | 57 | override func didReceiveMemoryWarning() { 58 | super.didReceiveMemoryWarning() 59 | // Dispose of any resources that can be recreated. 60 | } 61 | 62 | @objc func onClicked_button1() { 63 | let data = [["1983", "1984", "1985"], ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]] 64 | showGroupPicker(title: "Hello", groupData: data, selectedItems: ["1984", "6月"], onDone: { [unowned self] (indices, items) in 65 | self.labelIndices.text = "indices -- \(indices)" 66 | self.labelItems.text = "items -- \(items)" 67 | }, onCancel: { 68 | self.labelIndices.text = "selected nothing" 69 | self.labelItems.text = "selected nothing" 70 | }) 71 | } 72 | 73 | @objc func onClicked_button2() { 74 | if let path = Bundle.main.path(forResource: "chinese_regionalism", ofType: "json") { 75 | showCorrelationPicker(title: "城市", correlationalJsonFile: path, selectedItems: ["江苏", "无锡"], onDone: { [unowned self] (indices, items) in 76 | self.labelIndices.text = "indices -- \(indices)" 77 | self.labelItems.text = "items -- \(items)" 78 | }, onCancel: { 79 | self.labelIndices.text = "selected nothing" 80 | self.labelItems.text = "selected nothing" 81 | }) 82 | } 83 | } 84 | 85 | @objc func onClicked_button3() { 86 | showDatePicker(title: "时间", onConfigure: { 87 | $0.setDate(Date(), animated: false) 88 | $0.datePickerMode = .date 89 | }, onDone: { [unowned self] (date) in 90 | self.labelIndices.text = "" 91 | self.labelItems.text = "date -- \(date)" 92 | }, onCancel: { 93 | self.labelIndices.text = "" 94 | self.labelItems.text = "selected nothing" 95 | }) 96 | } 97 | } 98 | 99 | -------------------------------------------------------------------------------- /Example/PickerController/chinese_regionalism.json: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": [{ 3 | "value": "安徽", 4 | "nodes": [{ 5 | "value": "安庆" 6 | }, { 7 | "value": "蚌埠" 8 | }, { 9 | "value": "亳州" 10 | }, { 11 | "value": "巢湖" 12 | }, { 13 | "value": "池州" 14 | }, { 15 | "value": "滁州" 16 | }, { 17 | "value": "阜阳" 18 | }, { 19 | "value": "合肥" 20 | }, { 21 | "value": "淮北" 22 | }, { 23 | "value": "淮南" 24 | }, { 25 | "value": "黄山" 26 | }, { 27 | "value": "六安" 28 | }, { 29 | "value": "马鞍山" 30 | }, { 31 | "value": "宿州" 32 | }, { 33 | "value": "铜陵" 34 | }, { 35 | "value": "芜湖" 36 | }, { 37 | "value": "宣城" 38 | }] 39 | }, { 40 | "value": "福建", 41 | "nodes": [{ 42 | "value": "福州" 43 | }, { 44 | "value": "龙岩" 45 | }, { 46 | "value": "南平" 47 | }, { 48 | "value": "宁德" 49 | }, { 50 | "value": "莆田" 51 | }, { 52 | "value": "泉州" 53 | }, { 54 | "value": "三明" 55 | }, { 56 | "value": "厦门" 57 | }, { 58 | "value": "漳州" 59 | }] 60 | }, { 61 | "value": "甘肃", 62 | "nodes": [{ 63 | "value": "白银" 64 | }, { 65 | "value": "定西" 66 | }, { 67 | "value": "甘南藏族自治州" 68 | }, { 69 | "value": "嘉峪关" 70 | }, { 71 | "value": "金昌" 72 | }, { 73 | "value": "酒泉" 74 | }, { 75 | "value": "兰州" 76 | }, { 77 | "value": "临夏回族自治州" 78 | }, { 79 | "value": "陇南" 80 | }, { 81 | "value": "平凉" 82 | }, { 83 | "value": "庆阳" 84 | }, { 85 | "value": "天水" 86 | }, { 87 | "value": "武威" 88 | }, { 89 | "value": "张掖" 90 | }] 91 | }, { 92 | "value": "广东", 93 | "nodes": [{ 94 | "value": "潮州" 95 | }, { 96 | "value": "东莞" 97 | }, { 98 | "value": "佛山" 99 | }, { 100 | "value": "广州" 101 | }, { 102 | "value": "河源" 103 | }, { 104 | "value": "惠州" 105 | }, { 106 | "value": "江门" 107 | }, { 108 | "value": "揭阳" 109 | }, { 110 | "value": "茂名" 111 | }, { 112 | "value": "梅州" 113 | }, { 114 | "value": "清远" 115 | }, { 116 | "value": "汕头" 117 | }, { 118 | "value": "汕尾" 119 | }, { 120 | "value": "韶关" 121 | }, { 122 | "value": "深圳" 123 | }, { 124 | "value": "阳江" 125 | }, { 126 | "value": "云浮" 127 | }, { 128 | "value": "湛江" 129 | }, { 130 | "value": "肇庆" 131 | }, { 132 | "value": "中山" 133 | }, { 134 | "value": "珠海" 135 | }] 136 | }, { 137 | "value": "广西", 138 | "nodes": [{ 139 | "value": "百色" 140 | }, { 141 | "value": "北海" 142 | }, { 143 | "value": "崇左" 144 | }, { 145 | "value": "防城港" 146 | }, { 147 | "value": "贵港" 148 | }, { 149 | "value": "桂林" 150 | }, { 151 | "value": "河池" 152 | }, { 153 | "value": "贺州" 154 | }, { 155 | "value": "来宾" 156 | }, { 157 | "value": "柳州" 158 | }, { 159 | "value": "南宁" 160 | }, { 161 | "value": "钦州" 162 | }, { 163 | "value": "梧州" 164 | }, { 165 | "value": "玉林" 166 | }] 167 | }, { 168 | "value": "贵州", 169 | "nodes": [{ 170 | "value": "安顺" 171 | }, { 172 | "value": "毕节地区" 173 | }, { 174 | "value": "贵阳" 175 | }, { 176 | "value": "六盘水" 177 | }, { 178 | "value": "黔东南苗族侗族自治州" 179 | }, { 180 | "value": "黔南布依族苗族自治州" 181 | }, { 182 | "value": "黔西南布依族苗族自治州" 183 | }, { 184 | "value": "铜仁" 185 | }, { 186 | "value": "遵义" 187 | }] 188 | }, { 189 | "value": "海南", 190 | "nodes": [{ 191 | "value": "海口" 192 | }, { 193 | "value": "三亚" 194 | }] 195 | }, { 196 | "value": "河北", 197 | "nodes": [{ 198 | "value": "保定" 199 | }, { 200 | "value": "沧州" 201 | }, { 202 | "value": "承德" 203 | }, { 204 | "value": "邯郸" 205 | }, { 206 | "value": "衡水" 207 | }, { 208 | "value": "廊坊" 209 | }, { 210 | "value": "秦皇岛" 211 | }, { 212 | "value": "石家庄" 213 | }, { 214 | "value": "唐山" 215 | }, { 216 | "value": "邢台" 217 | }, { 218 | "value": "张家口" 219 | }] 220 | }, { 221 | "value": "河南", 222 | "nodes": [{ 223 | "value": "安阳" 224 | }, { 225 | "value": "鹤壁" 226 | }, { 227 | "value": "焦作" 228 | }, { 229 | "value": "开封" 230 | }, { 231 | "value": "漯河" 232 | }, { 233 | "value": "洛阳" 234 | }, { 235 | "value": "南阳" 236 | }, { 237 | "value": "平顶山" 238 | }, { 239 | "value": "濮阳" 240 | }, { 241 | "value": "三门峡" 242 | }, { 243 | "value": "商丘" 244 | }, { 245 | "value": "新乡" 246 | }, { 247 | "value": "信阳" 248 | }, { 249 | "value": "许昌" 250 | }, { 251 | "value": "郑州" 252 | }, { 253 | "value": "周口" 254 | }, { 255 | "value": "驻马店" 256 | }] 257 | }, { 258 | "value": "黑龙江", 259 | "nodes": [{ 260 | "value": "大庆" 261 | }, { 262 | "value": "大兴安岭地区" 263 | }, { 264 | "value": "哈尔滨" 265 | }, { 266 | "value": "鹤岗" 267 | }, { 268 | "value": "黑河" 269 | }, { 270 | "value": "鸡西" 271 | }, { 272 | "value": "佳木斯" 273 | }, { 274 | "value": "牡丹江" 275 | }, { 276 | "value": "齐齐哈尔" 277 | }, { 278 | "value": "七台河" 279 | }, { 280 | "value": "双鸭山" 281 | }, { 282 | "value": "绥化" 283 | }, { 284 | "value": "伊春" 285 | }] 286 | }, { 287 | "value": "湖北", 288 | "nodes": [{ 289 | "value": "鄂州" 290 | }, { 291 | "value": "恩施土家族苗族自治州" 292 | }, { 293 | "value": "黄冈" 294 | }, { 295 | "value": "黄石" 296 | }, { 297 | "value": "荆门" 298 | }, { 299 | "value": "荆州" 300 | }, { 301 | "value": "十堰" 302 | }, { 303 | "value": "随州" 304 | }, { 305 | "value": "武汉" 306 | }, { 307 | "value": "咸宁" 308 | }, { 309 | "value": "襄樊" 310 | }, { 311 | "value": "孝感" 312 | }, { 313 | "value": "宜昌" 314 | }] 315 | }, { 316 | "value": "湖南", 317 | "nodes": [{ 318 | "value": "常德" 319 | }, { 320 | "value": "郴州" 321 | }, { 322 | "value": "衡阳" 323 | }, { 324 | "value": "怀化" 325 | }, { 326 | "value": "娄底" 327 | }, { 328 | "value": "邵阳" 329 | }, { 330 | "value": "湘潭" 331 | }, { 332 | "value": "湘西土家族苗族自治州" 333 | }, { 334 | "value": "益阳" 335 | }, { 336 | "value": "永州" 337 | }, { 338 | "value": "岳阳" 339 | }, { 340 | "value": "张家界" 341 | }, { 342 | "value": "长沙" 343 | }, { 344 | "value": "株洲" 345 | }] 346 | }, { 347 | "value": "吉林", 348 | "nodes": [{ 349 | "value": "白城" 350 | }, { 351 | "value": "白山" 352 | }, { 353 | "value": "吉林" 354 | }, { 355 | "value": "辽源" 356 | }, { 357 | "value": "四平" 358 | }, { 359 | "value": "松原" 360 | }, { 361 | "value": "通化" 362 | }, { 363 | "value": "延边朝鲜族自治州" 364 | }, { 365 | "value": "长春" 366 | }] 367 | }, { 368 | "value": "江苏", 369 | "nodes": [{ 370 | "value": "常州" 371 | }, { 372 | "value": "淮安" 373 | }, { 374 | "value": "连云港" 375 | }, { 376 | "value": "南京" 377 | }, { 378 | "value": "南通" 379 | }, { 380 | "value": "宿迁" 381 | }, { 382 | "value": "苏州" 383 | }, { 384 | "value": "泰州" 385 | }, { 386 | "value": "无锡" 387 | }, { 388 | "value": "徐州" 389 | }, { 390 | "value": "盐城" 391 | }, { 392 | "value": "扬州" 393 | }, { 394 | "value": "镇江" 395 | }] 396 | }, { 397 | "value": "江西", 398 | "nodes": [{ 399 | "value": "抚州" 400 | }, { 401 | "value": "赣州" 402 | }, { 403 | "value": "吉安" 404 | }, { 405 | "value": "景德镇" 406 | }, { 407 | "value": "九江" 408 | }, { 409 | "value": "南昌" 410 | }, { 411 | "value": "萍乡" 412 | }, { 413 | "value": "上饶" 414 | }, { 415 | "value": "新余" 416 | }, { 417 | "value": "宜春" 418 | }, { 419 | "value": "鹰潭" 420 | }] 421 | }, { 422 | "value": "辽宁", 423 | "nodes": [{ 424 | "value": "鞍山" 425 | }, { 426 | "value": "本溪" 427 | }, { 428 | "value": "朝阳" 429 | }, { 430 | "value": "大连" 431 | }, { 432 | "value": "丹东" 433 | }, { 434 | "value": "抚顺" 435 | }, { 436 | "value": "阜新" 437 | }, { 438 | "value": "葫芦岛" 439 | }, { 440 | "value": "锦州" 441 | }, { 442 | "value": "辽阳" 443 | }, { 444 | "value": "盘锦" 445 | }, { 446 | "value": "沈阳" 447 | }, { 448 | "value": "铁岭" 449 | }, { 450 | "value": "营口" 451 | }] 452 | }, { 453 | "value": "内蒙古", 454 | "nodes": [{ 455 | "value": "阿拉善盟" 456 | }, { 457 | "value": "巴彦淖尔" 458 | }, { 459 | "value": "包头" 460 | }, { 461 | "value": "赤峰" 462 | }, { 463 | "value": "鄂尔多斯" 464 | }, { 465 | "value": "呼和浩特" 466 | }, { 467 | "value": "呼伦贝尔" 468 | }, { 469 | "value": "通辽" 470 | }, { 471 | "value": "乌海" 472 | }, { 473 | "value": "乌兰察布" 474 | }, { 475 | "value": "锡林郭勒盟" 476 | }, { 477 | "value": "兴安盟" 478 | }] 479 | }, { 480 | "value": "宁夏", 481 | "nodes": [{ 482 | "value": "固原" 483 | }, { 484 | "value": "石嘴山" 485 | }, { 486 | "value": "吴忠" 487 | }, { 488 | "value": "银川" 489 | }, { 490 | "value": "中卫" 491 | }] 492 | }, { 493 | "value": "青海", 494 | "nodes": [{ 495 | "value": "果洛藏族自治州" 496 | }, { 497 | "value": "海北藏族自治州" 498 | }, { 499 | "value": "海东地区" 500 | }, { 501 | "value": "海南藏族自治州" 502 | }, { 503 | "value": "海西蒙古族藏族自治州" 504 | }, { 505 | "value": "黄南藏族自治州" 506 | }, { 507 | "value": "西宁" 508 | }, { 509 | "value": "玉树藏族自治州" 510 | }] 511 | }, { 512 | "value": "山东", 513 | "nodes": [{ 514 | "value": "滨州" 515 | }, { 516 | "value": "德州" 517 | }, { 518 | "value": "东营" 519 | }, { 520 | "value": "菏泽" 521 | }, { 522 | "value": "济南" 523 | }, { 524 | "value": "济宁" 525 | }, { 526 | "value": "莱芜" 527 | }, { 528 | "value": "聊城" 529 | }, { 530 | "value": "临沂" 531 | }, { 532 | "value": "青岛" 533 | }, { 534 | "value": "日照" 535 | }, { 536 | "value": "泰安" 537 | }, { 538 | "value": "潍坊" 539 | }, { 540 | "value": "威海" 541 | }, { 542 | "value": "烟台" 543 | }, { 544 | "value": "枣庄" 545 | }, { 546 | "value": "淄博" 547 | }] 548 | }, { 549 | "value": "陕西", 550 | "nodes": [{ 551 | "value": "安康" 552 | }, { 553 | "value": "宝鸡" 554 | }, { 555 | "value": "汉中" 556 | }, { 557 | "value": "商洛" 558 | }, { 559 | "value": "铜川" 560 | }, { 561 | "value": "渭南" 562 | }, { 563 | "value": "西安" 564 | }, { 565 | "value": "咸阳" 566 | }, { 567 | "value": "延安" 568 | }, { 569 | "value": "榆林" 570 | }] 571 | }, { 572 | "value": "山西", 573 | "nodes": [{ 574 | "value": "大同" 575 | }, { 576 | "value": "晋城" 577 | }, { 578 | "value": "晋中" 579 | }, { 580 | "value": "临汾" 581 | }, { 582 | "value": "吕梁" 583 | }, { 584 | "value": "朔州" 585 | }, { 586 | "value": "太原" 587 | }, { 588 | "value": "阳泉" 589 | }, { 590 | "value": "沂州" 591 | }, { 592 | "value": "运城" 593 | }, { 594 | "value": "长治" 595 | }] 596 | }, { 597 | "value": "四川", 598 | "nodes": [{ 599 | "value": "阿坝藏族羌族自治州" 600 | }, { 601 | "value": "巴中" 602 | }, { 603 | "value": "成都" 604 | }, { 605 | "value": "达州" 606 | }, { 607 | "value": "德阳" 608 | }, { 609 | "value": "甘孜藏族自治州" 610 | }, { 611 | "value": "广安" 612 | }, { 613 | "value": "广元" 614 | }, { 615 | "value": "乐山" 616 | }, { 617 | "value": "凉山彝族自治州" 618 | }, { 619 | "value": "泸州" 620 | }, { 621 | "value": "眉山" 622 | }, { 623 | "value": "绵阳" 624 | }, { 625 | "value": "南充" 626 | }, { 627 | "value": "内江" 628 | }, { 629 | "value": "攀枝花" 630 | }, { 631 | "value": "遂宁" 632 | }, { 633 | "value": "雅安" 634 | }, { 635 | "value": "宜宾" 636 | }, { 637 | "value": "自贡" 638 | }, { 639 | "value": "资阳" 640 | }] 641 | }, { 642 | "value": "西藏", 643 | "nodes": [{ 644 | "value": "阿里地区" 645 | }, { 646 | "value": "昌都地区" 647 | }, { 648 | "value": "拉萨" 649 | }, { 650 | "value": "林芝地区" 651 | }, { 652 | "value": "那曲地区" 653 | }, { 654 | "value": "日喀则地区" 655 | }, { 656 | "value": "山南地区" 657 | }] 658 | }, { 659 | "value": "新疆", 660 | "nodes": [{ 661 | "value": "阿克苏地区" 662 | }, { 663 | "value": "阿勒泰地区" 664 | }, { 665 | "value": "巴音郭楞蒙古自治州" 666 | }, { 667 | "value": "博尔塔拉蒙古自治州" 668 | }, { 669 | "value": "昌吉回族自治州" 670 | }, { 671 | "value": "哈密地区" 672 | }, { 673 | "value": "和田地区" 674 | }, { 675 | "value": "喀什地区" 676 | }, { 677 | "value": "克拉玛依" 678 | }, { 679 | "value": "克孜勒苏柯尔克孜自治州" 680 | }, { 681 | "value": "塔城地区" 682 | }, { 683 | "value": "吐鲁番地区" 684 | }, { 685 | "value": "乌鲁木齐" 686 | }, { 687 | "value": "伊犁哈萨克自治州" 688 | }] 689 | }, { 690 | "value": "云南", 691 | "nodes": [{ 692 | "value": "保山" 693 | }, { 694 | "value": "楚雄彝族自治州" 695 | }, { 696 | "value": "大理白族自治州" 697 | }, { 698 | "value": "德宏傣族景颇族自治州" 699 | }, { 700 | "value": "迪庆藏族自治州" 701 | }, { 702 | "value": "红河哈尼族彝族自治州" 703 | }, { 704 | "value": "昆明" 705 | }, { 706 | "value": "丽江" 707 | }, { 708 | "value": "临沧" 709 | }, { 710 | "value": "怒江僳僳族自治州" 711 | }, { 712 | "value": "普洱" 713 | }, { 714 | "value": "曲靖" 715 | }, { 716 | "value": "邵通" 717 | }, { 718 | "value": "文山壮族苗族自治州" 719 | }, { 720 | "value": "西双版纳傣族自治州" 721 | }, { 722 | "value": "玉溪" 723 | }] 724 | }, { 725 | "value": "浙江", 726 | "nodes": [{ 727 | "value": "杭州" 728 | }, { 729 | "value": "湖州" 730 | }, { 731 | "value": "嘉兴" 732 | }, { 733 | "value": "金华" 734 | }, { 735 | "value": "丽水" 736 | }, { 737 | "value": "宁波" 738 | }, { 739 | "value": "衢州" 740 | }, { 741 | "value": "绍兴" 742 | }, { 743 | "value": "台州" 744 | }, { 745 | "value": "温州" 746 | }, { 747 | "value": "舟山" 748 | }] 749 | }, { 750 | "value": "北京", 751 | "nodes": [{ 752 | "value": "北京市" 753 | }] 754 | }, { 755 | "value": "上海", 756 | "nodes": [{ 757 | "value": "上海市" 758 | }] 759 | }, { 760 | "value": "天津", 761 | "nodes": [{ 762 | "value": "天津市" 763 | }] 764 | }, { 765 | "value": "重庆", 766 | "nodes": [{ 767 | "value": "重庆市" 768 | }] 769 | }, ] 770 | } 771 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | target 'PickerController_Example' do 4 | pod 'PickerController', :path => '../' 5 | 6 | end 7 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - PickerController (0.1.2) 3 | 4 | DEPENDENCIES: 5 | - PickerController (from `../`) 6 | 7 | EXTERNAL SOURCES: 8 | PickerController: 9 | :path: "../" 10 | 11 | SPEC CHECKSUMS: 12 | PickerController: 7acd78973556c6b2e9430cfd310203ede48bb882 13 | 14 | PODFILE CHECKSUM: 5cfd8a4f1a56a0d1f776205c6978c82c8027f071 15 | 16 | COCOAPODS: 1.5.3 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 xiongxiong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PickerController.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint PickerController.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'PickerController' 11 | s.version = '0.1.2' 12 | s.summary = 'PickerController, has many functions.' 13 | 14 | # This description is used to generate tags and improve search results. 15 | # * Think: What does it do? Why did you write it? What is the focus? 16 | # * Try to keep it short, snappy and to the point. 17 | # * Write the description between the DESC delimiters below. 18 | # * Finally, don't worry about the indent, CocoaPods strips it! 19 | 20 | s.description = <<-DESC 21 | PickerController, can make correlational pick. love it. 22 | DESC 23 | 24 | s.homepage = 'https://github.com/xiongxiong/PickerController' 25 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' 26 | s.license = { :type => 'MIT', :file => 'LICENSE' } 27 | s.author = { 'xiongxiong' => 'xiongxiong0619@gmail.com' } 28 | s.source = { :git => 'https://github.com/xiongxiong/PickerController.git', :tag => s.version.to_s } 29 | # s.social_media_url = 'https://twitter.com/' 30 | 31 | s.ios.deployment_target = '8.0' 32 | 33 | s.source_files = 'PickerController/Classes/**/*.swift' 34 | s.resources = 'PickerController/Assets/**/*.json' 35 | 36 | # s.resource_bundles = { 37 | # 'PickerController' => ['PickerController/Assets/**/*.json'] 38 | # } 39 | 40 | # s.public_header_files = 'PickerController/Classes/**/*.h' 41 | s.frameworks = 'UIKit' 42 | end 43 | 44 | -------------------------------------------------------------------------------- /PickerController.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D8180B5F21B7981C009D93E7 /* PickerController_Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8180B5121B7981C009D93E7 /* PickerController_Base.swift */; }; 11 | D8180B6121B7981C009D93E7 /* PickerControl_Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8180B5321B7981C009D93E7 /* PickerControl_Date.swift */; }; 12 | D8180B6221B7981C009D93E7 /* PickerController_Group.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8180B5421B7981C009D93E7 /* PickerController_Group.swift */; }; 13 | D8180B6321B7981C009D93E7 /* PickerControl_Group.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8180B5521B7981C009D93E7 /* PickerControl_Group.swift */; }; 14 | D8180B6421B7981C009D93E7 /* PickerControl_Correlation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8180B5621B7981C009D93E7 /* PickerControl_Correlation.swift */; }; 15 | D8180B6521B7981C009D93E7 /* PickerControl_Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8180B5721B7981C009D93E7 /* PickerControl_Base.swift */; }; 16 | D8180B6621B7981C009D93E7 /* Tree.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8180B5821B7981C009D93E7 /* Tree.swift */; }; 17 | D8180B6721B7981C009D93E7 /* PickerController_Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8180B5921B7981C009D93E7 /* PickerController_Date.swift */; }; 18 | D8180B6821B7981C009D93E7 /* PickerController_Correlation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8180B5A21B7981C009D93E7 /* PickerController_Correlation.swift */; }; 19 | D8180B6921B7981C009D93E7 /* Tree+Height.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8180B5B21B7981C009D93E7 /* Tree+Height.swift */; }; 20 | D8180B6A21B7981C009D93E7 /* UIViewController+ShowPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8180B5C21B7981C009D93E7 /* UIViewController+ShowPicker.swift */; }; 21 | D8180B7021B79B82009D93E7 /* PickerController.h in Headers */ = {isa = PBXBuildFile; fileRef = D8180B6F21B79B82009D93E7 /* PickerController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXFileReference section */ 25 | 42E34E0A1DD888FE002BFCC3 /* PickerController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PickerController.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | D8180B5121B7981C009D93E7 /* PickerController_Base.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerController_Base.swift; sourceTree = ""; }; 27 | D8180B5321B7981C009D93E7 /* PickerControl_Date.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerControl_Date.swift; sourceTree = ""; }; 28 | D8180B5421B7981C009D93E7 /* PickerController_Group.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerController_Group.swift; sourceTree = ""; }; 29 | D8180B5521B7981C009D93E7 /* PickerControl_Group.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerControl_Group.swift; sourceTree = ""; }; 30 | D8180B5621B7981C009D93E7 /* PickerControl_Correlation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerControl_Correlation.swift; sourceTree = ""; }; 31 | D8180B5721B7981C009D93E7 /* PickerControl_Base.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerControl_Base.swift; sourceTree = ""; }; 32 | D8180B5821B7981C009D93E7 /* Tree.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tree.swift; sourceTree = ""; }; 33 | D8180B5921B7981C009D93E7 /* PickerController_Date.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerController_Date.swift; sourceTree = ""; }; 34 | D8180B5A21B7981C009D93E7 /* PickerController_Correlation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerController_Correlation.swift; sourceTree = ""; }; 35 | D8180B5B21B7981C009D93E7 /* Tree+Height.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Tree+Height.swift"; sourceTree = ""; }; 36 | D8180B5C21B7981C009D93E7 /* UIViewController+ShowPicker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+ShowPicker.swift"; sourceTree = ""; }; 37 | D8180B6F21B79B82009D93E7 /* PickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PickerController.h; sourceTree = ""; }; 38 | D8180B7721B79F3F009D93E7 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | 42E34E061DD888FE002BFCC3 /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXFrameworksBuildPhase section */ 50 | 51 | /* Begin PBXGroup section */ 52 | 42E34E001DD888FE002BFCC3 = { 53 | isa = PBXGroup; 54 | children = ( 55 | D8180B4F21B7981C009D93E7 /* PickerController */, 56 | 42E34E0B1DD888FE002BFCC3 /* Products */, 57 | ); 58 | sourceTree = ""; 59 | }; 60 | 42E34E0B1DD888FE002BFCC3 /* Products */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 42E34E0A1DD888FE002BFCC3 /* PickerController.framework */, 64 | ); 65 | name = Products; 66 | sourceTree = ""; 67 | }; 68 | D8180B4F21B7981C009D93E7 /* PickerController */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | D8180B5021B7981C009D93E7 /* Classes */, 72 | D8180B5D21B7981C009D93E7 /* Assets */, 73 | D8180B7921B7A1D4009D93E7 /* Supporting Files */, 74 | ); 75 | path = PickerController; 76 | sourceTree = ""; 77 | }; 78 | D8180B5021B7981C009D93E7 /* Classes */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | D8180B6F21B79B82009D93E7 /* PickerController.h */, 82 | D8180B5121B7981C009D93E7 /* PickerController_Base.swift */, 83 | D8180B5321B7981C009D93E7 /* PickerControl_Date.swift */, 84 | D8180B5421B7981C009D93E7 /* PickerController_Group.swift */, 85 | D8180B5521B7981C009D93E7 /* PickerControl_Group.swift */, 86 | D8180B5621B7981C009D93E7 /* PickerControl_Correlation.swift */, 87 | D8180B5721B7981C009D93E7 /* PickerControl_Base.swift */, 88 | D8180B5821B7981C009D93E7 /* Tree.swift */, 89 | D8180B5921B7981C009D93E7 /* PickerController_Date.swift */, 90 | D8180B5A21B7981C009D93E7 /* PickerController_Correlation.swift */, 91 | D8180B5B21B7981C009D93E7 /* Tree+Height.swift */, 92 | D8180B5C21B7981C009D93E7 /* UIViewController+ShowPicker.swift */, 93 | ); 94 | path = Classes; 95 | sourceTree = ""; 96 | }; 97 | D8180B5D21B7981C009D93E7 /* Assets */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | ); 101 | path = Assets; 102 | sourceTree = ""; 103 | }; 104 | D8180B7921B7A1D4009D93E7 /* Supporting Files */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | D8180B7721B79F3F009D93E7 /* Info.plist */, 108 | ); 109 | name = "Supporting Files"; 110 | path = Classes; 111 | sourceTree = ""; 112 | }; 113 | /* End PBXGroup section */ 114 | 115 | /* Begin PBXHeadersBuildPhase section */ 116 | 42E34E071DD888FE002BFCC3 /* Headers */ = { 117 | isa = PBXHeadersBuildPhase; 118 | buildActionMask = 2147483647; 119 | files = ( 120 | D8180B7021B79B82009D93E7 /* PickerController.h in Headers */, 121 | ); 122 | runOnlyForDeploymentPostprocessing = 0; 123 | }; 124 | /* End PBXHeadersBuildPhase section */ 125 | 126 | /* Begin PBXNativeTarget section */ 127 | 42E34E091DD888FE002BFCC3 /* PickerController */ = { 128 | isa = PBXNativeTarget; 129 | buildConfigurationList = 42E34E121DD888FE002BFCC3 /* Build configuration list for PBXNativeTarget "PickerController" */; 130 | buildPhases = ( 131 | 42E34E051DD888FE002BFCC3 /* Sources */, 132 | 42E34E061DD888FE002BFCC3 /* Frameworks */, 133 | 42E34E071DD888FE002BFCC3 /* Headers */, 134 | 42E34E081DD888FE002BFCC3 /* Resources */, 135 | ); 136 | buildRules = ( 137 | ); 138 | dependencies = ( 139 | ); 140 | name = PickerController; 141 | productName = PickerController; 142 | productReference = 42E34E0A1DD888FE002BFCC3 /* PickerController.framework */; 143 | productType = "com.apple.product-type.framework"; 144 | }; 145 | /* End PBXNativeTarget section */ 146 | 147 | /* Begin PBXProject section */ 148 | 42E34E011DD888FE002BFCC3 /* Project object */ = { 149 | isa = PBXProject; 150 | attributes = { 151 | LastUpgradeCheck = 1010; 152 | ORGANIZATIONNAME = snowflyer; 153 | TargetAttributes = { 154 | 42E34E091DD888FE002BFCC3 = { 155 | CreatedOnToolsVersion = 8.1; 156 | LastSwiftMigration = 0810; 157 | ProvisioningStyle = Automatic; 158 | }; 159 | }; 160 | }; 161 | buildConfigurationList = 42E34E041DD888FE002BFCC3 /* Build configuration list for PBXProject "PickerController" */; 162 | compatibilityVersion = "Xcode 3.2"; 163 | developmentRegion = English; 164 | hasScannedForEncodings = 0; 165 | knownRegions = ( 166 | en, 167 | ); 168 | mainGroup = 42E34E001DD888FE002BFCC3; 169 | productRefGroup = 42E34E0B1DD888FE002BFCC3 /* Products */; 170 | projectDirPath = ""; 171 | projectRoot = ""; 172 | targets = ( 173 | 42E34E091DD888FE002BFCC3 /* PickerController */, 174 | ); 175 | }; 176 | /* End PBXProject section */ 177 | 178 | /* Begin PBXResourcesBuildPhase section */ 179 | 42E34E081DD888FE002BFCC3 /* Resources */ = { 180 | isa = PBXResourcesBuildPhase; 181 | buildActionMask = 2147483647; 182 | files = ( 183 | ); 184 | runOnlyForDeploymentPostprocessing = 0; 185 | }; 186 | /* End PBXResourcesBuildPhase section */ 187 | 188 | /* Begin PBXSourcesBuildPhase section */ 189 | 42E34E051DD888FE002BFCC3 /* Sources */ = { 190 | isa = PBXSourcesBuildPhase; 191 | buildActionMask = 2147483647; 192 | files = ( 193 | D8180B6621B7981C009D93E7 /* Tree.swift in Sources */, 194 | D8180B6521B7981C009D93E7 /* PickerControl_Base.swift in Sources */, 195 | D8180B5F21B7981C009D93E7 /* PickerController_Base.swift in Sources */, 196 | D8180B6221B7981C009D93E7 /* PickerController_Group.swift in Sources */, 197 | D8180B6421B7981C009D93E7 /* PickerControl_Correlation.swift in Sources */, 198 | D8180B6721B7981C009D93E7 /* PickerController_Date.swift in Sources */, 199 | D8180B6821B7981C009D93E7 /* PickerController_Correlation.swift in Sources */, 200 | D8180B6121B7981C009D93E7 /* PickerControl_Date.swift in Sources */, 201 | D8180B6921B7981C009D93E7 /* Tree+Height.swift in Sources */, 202 | D8180B6321B7981C009D93E7 /* PickerControl_Group.swift in Sources */, 203 | D8180B6A21B7981C009D93E7 /* UIViewController+ShowPicker.swift in Sources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXSourcesBuildPhase section */ 208 | 209 | /* Begin XCBuildConfiguration section */ 210 | 42E34E101DD888FE002BFCC3 /* Debug */ = { 211 | isa = XCBuildConfiguration; 212 | buildSettings = { 213 | ALWAYS_SEARCH_USER_PATHS = NO; 214 | CLANG_ANALYZER_NONNULL = YES; 215 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 216 | CLANG_CXX_LIBRARY = "libc++"; 217 | CLANG_ENABLE_MODULES = YES; 218 | CLANG_ENABLE_OBJC_ARC = YES; 219 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 220 | CLANG_WARN_BOOL_CONVERSION = YES; 221 | CLANG_WARN_COMMA = YES; 222 | CLANG_WARN_CONSTANT_CONVERSION = YES; 223 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 224 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 225 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 226 | CLANG_WARN_EMPTY_BODY = YES; 227 | CLANG_WARN_ENUM_CONVERSION = YES; 228 | CLANG_WARN_INFINITE_RECURSION = YES; 229 | CLANG_WARN_INT_CONVERSION = YES; 230 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 231 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 232 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 233 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 234 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 235 | CLANG_WARN_STRICT_PROTOTYPES = YES; 236 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 237 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 238 | CLANG_WARN_UNREACHABLE_CODE = YES; 239 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 240 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 241 | COPY_PHASE_STRIP = NO; 242 | CURRENT_PROJECT_VERSION = 1; 243 | DEBUG_INFORMATION_FORMAT = dwarf; 244 | ENABLE_STRICT_OBJC_MSGSEND = YES; 245 | ENABLE_TESTABILITY = YES; 246 | GCC_C_LANGUAGE_STANDARD = gnu99; 247 | GCC_DYNAMIC_NO_PIC = NO; 248 | GCC_NO_COMMON_BLOCKS = YES; 249 | GCC_OPTIMIZATION_LEVEL = 0; 250 | GCC_PREPROCESSOR_DEFINITIONS = ( 251 | "DEBUG=1", 252 | "$(inherited)", 253 | ); 254 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 255 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 256 | GCC_WARN_UNDECLARED_SELECTOR = YES; 257 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 258 | GCC_WARN_UNUSED_FUNCTION = YES; 259 | GCC_WARN_UNUSED_VARIABLE = YES; 260 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 261 | MTL_ENABLE_DEBUG_INFO = YES; 262 | ONLY_ACTIVE_ARCH = YES; 263 | SDKROOT = iphoneos; 264 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 265 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 266 | TARGETED_DEVICE_FAMILY = "1,2"; 267 | VERSIONING_SYSTEM = "apple-generic"; 268 | VERSION_INFO_PREFIX = ""; 269 | }; 270 | name = Debug; 271 | }; 272 | 42E34E111DD888FE002BFCC3 /* Release */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ALWAYS_SEARCH_USER_PATHS = NO; 276 | CLANG_ANALYZER_NONNULL = YES; 277 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 278 | CLANG_CXX_LIBRARY = "libc++"; 279 | CLANG_ENABLE_MODULES = YES; 280 | CLANG_ENABLE_OBJC_ARC = YES; 281 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 282 | CLANG_WARN_BOOL_CONVERSION = YES; 283 | CLANG_WARN_COMMA = YES; 284 | CLANG_WARN_CONSTANT_CONVERSION = YES; 285 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 286 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 287 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 288 | CLANG_WARN_EMPTY_BODY = YES; 289 | CLANG_WARN_ENUM_CONVERSION = YES; 290 | CLANG_WARN_INFINITE_RECURSION = YES; 291 | CLANG_WARN_INT_CONVERSION = YES; 292 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 293 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 294 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 295 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 296 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 297 | CLANG_WARN_STRICT_PROTOTYPES = YES; 298 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 299 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 300 | CLANG_WARN_UNREACHABLE_CODE = YES; 301 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 302 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 303 | COPY_PHASE_STRIP = NO; 304 | CURRENT_PROJECT_VERSION = 1; 305 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 306 | ENABLE_NS_ASSERTIONS = NO; 307 | ENABLE_STRICT_OBJC_MSGSEND = YES; 308 | GCC_C_LANGUAGE_STANDARD = gnu99; 309 | GCC_NO_COMMON_BLOCKS = YES; 310 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 311 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 312 | GCC_WARN_UNDECLARED_SELECTOR = YES; 313 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 314 | GCC_WARN_UNUSED_FUNCTION = YES; 315 | GCC_WARN_UNUSED_VARIABLE = YES; 316 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 317 | MTL_ENABLE_DEBUG_INFO = NO; 318 | SDKROOT = iphoneos; 319 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 320 | TARGETED_DEVICE_FAMILY = "1,2"; 321 | VALIDATE_PRODUCT = YES; 322 | VERSIONING_SYSTEM = "apple-generic"; 323 | VERSION_INFO_PREFIX = ""; 324 | }; 325 | name = Release; 326 | }; 327 | 42E34E131DD888FE002BFCC3 /* Debug */ = { 328 | isa = XCBuildConfiguration; 329 | buildSettings = { 330 | CODE_SIGN_IDENTITY = ""; 331 | DEFINES_MODULE = YES; 332 | DYLIB_COMPATIBILITY_VERSION = 1; 333 | DYLIB_CURRENT_VERSION = 1; 334 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 335 | INFOPLIST_FILE = PickerController/Classes/Info.plist; 336 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 337 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 338 | PRODUCT_BUNDLE_IDENTIFIER = com.snowflyer.PickerController; 339 | PRODUCT_NAME = "$(TARGET_NAME)"; 340 | SKIP_INSTALL = YES; 341 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 342 | SWIFT_VERSION = 4.2; 343 | }; 344 | name = Debug; 345 | }; 346 | 42E34E141DD888FE002BFCC3 /* Release */ = { 347 | isa = XCBuildConfiguration; 348 | buildSettings = { 349 | CODE_SIGN_IDENTITY = ""; 350 | DEFINES_MODULE = YES; 351 | DYLIB_COMPATIBILITY_VERSION = 1; 352 | DYLIB_CURRENT_VERSION = 1; 353 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 354 | INFOPLIST_FILE = PickerController/Classes/Info.plist; 355 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 356 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 357 | PRODUCT_BUNDLE_IDENTIFIER = com.snowflyer.PickerController; 358 | PRODUCT_NAME = "$(TARGET_NAME)"; 359 | SKIP_INSTALL = YES; 360 | SWIFT_VERSION = 4.2; 361 | }; 362 | name = Release; 363 | }; 364 | /* End XCBuildConfiguration section */ 365 | 366 | /* Begin XCConfigurationList section */ 367 | 42E34E041DD888FE002BFCC3 /* Build configuration list for PBXProject "PickerController" */ = { 368 | isa = XCConfigurationList; 369 | buildConfigurations = ( 370 | 42E34E101DD888FE002BFCC3 /* Debug */, 371 | 42E34E111DD888FE002BFCC3 /* Release */, 372 | ); 373 | defaultConfigurationIsVisible = 0; 374 | defaultConfigurationName = Release; 375 | }; 376 | 42E34E121DD888FE002BFCC3 /* Build configuration list for PBXNativeTarget "PickerController" */ = { 377 | isa = XCConfigurationList; 378 | buildConfigurations = ( 379 | 42E34E131DD888FE002BFCC3 /* Debug */, 380 | 42E34E141DD888FE002BFCC3 /* Release */, 381 | ); 382 | defaultConfigurationIsVisible = 0; 383 | defaultConfigurationName = Release; 384 | }; 385 | /* End XCConfigurationList section */ 386 | }; 387 | rootObject = 42E34E011DD888FE002BFCC3 /* Project object */; 388 | } 389 | -------------------------------------------------------------------------------- /PickerController.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PickerController.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PickerController.xcodeproj/xcshareddata/xcschemes/PickerController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /PickerController/Classes/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /PickerController/Classes/PickerControl_Base.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CommonPicker.swift 3 | // CorrelationPicker 4 | // 5 | // Created by 王继荣 on 09/11/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public typealias ClosureDone = (_ selectedIndices: [Int], _ selectedStrings: [String]) -> Void 12 | public typealias ClosureDoneWithTreeNode = (_ selectedIndices: [Int], _ selectedStrings: [TreeNode]) -> Void 13 | public typealias ClosureCancel = () -> Void 14 | 15 | public class PickerControl_Base: UIControl { 16 | 17 | var pickerView: UIView { 18 | return UIView() 19 | } 20 | var toolBar = UIView() 21 | var titleLabel = UILabel() 22 | var cancelBtn = UIButton(type: .system) 23 | var doneBtn = UIButton(type: .system) 24 | var onCancel: ClosureCancel? 25 | 26 | override init(frame: CGRect) { 27 | super.init(frame: frame) 28 | 29 | addSubview(toolBar) 30 | addSubview(pickerView) 31 | 32 | toolBar.addSubview(cancelBtn) 33 | toolBar.addSubview(doneBtn) 34 | toolBar.addSubview(titleLabel) 35 | 36 | toolBar.translatesAutoresizingMaskIntoConstraints = false 37 | addConstraint(NSLayoutConstraint(item: toolBar, attribute: .leading, relatedBy: .equal, toItem: self, attribute: .leading, multiplier: 1, constant: 0)) 38 | addConstraint(NSLayoutConstraint(item: toolBar, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1, constant: 0)) 39 | addConstraint(NSLayoutConstraint(item: toolBar, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1, constant: 0)) 40 | addConstraint(NSLayoutConstraint(item: toolBar, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: 40)) 41 | 42 | pickerView.translatesAutoresizingMaskIntoConstraints = false 43 | addConstraint(NSLayoutConstraint(item: pickerView, attribute: .leading, relatedBy: .equal, toItem: self, attribute: .leading, multiplier: 1, constant: 0)) 44 | addConstraint(NSLayoutConstraint(item: pickerView, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1, constant: 0)) 45 | addConstraint(NSLayoutConstraint(item: toolBar, attribute: .bottom, relatedBy: .equal, toItem: pickerView, attribute: .top, multiplier: 1, constant: 0)) 46 | addConstraint(NSLayoutConstraint(item: pickerView, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1, constant: 0)) 47 | 48 | cancelBtn.translatesAutoresizingMaskIntoConstraints = false 49 | addConstraint(NSLayoutConstraint(item: cancelBtn, attribute: .leading, relatedBy: .equal, toItem: toolBar, attribute: .leading, multiplier: 1, constant: 15)) 50 | addConstraint(NSLayoutConstraint(item: cancelBtn, attribute: .top, relatedBy: .equal, toItem: toolBar, attribute: .top, multiplier: 1, constant: 0)) 51 | addConstraint(NSLayoutConstraint(item: cancelBtn, attribute: .bottom, relatedBy: .equal, toItem: toolBar, attribute: .bottom, multiplier: 1, constant: 0)) 52 | cancelBtn.setTitle("Cancel", for: .normal) 53 | cancelBtn.addTarget(self, action: #selector(didCancel), for: .touchUpInside) 54 | 55 | doneBtn.translatesAutoresizingMaskIntoConstraints = false 56 | addConstraint(NSLayoutConstraint(item: doneBtn, attribute: .trailing, relatedBy: .equal, toItem: toolBar, attribute: .trailing, multiplier: 1, constant: -15)) 57 | addConstraint(NSLayoutConstraint(item: doneBtn, attribute: .top, relatedBy: .equal, toItem: toolBar, attribute: .top, multiplier: 1, constant: 0)) 58 | addConstraint(NSLayoutConstraint(item: doneBtn, attribute: .bottom, relatedBy: .equal, toItem: toolBar, attribute: .bottom, multiplier: 1, constant: 0)) 59 | doneBtn.setTitle("Done", for: .normal) 60 | doneBtn.addTarget(self, action: #selector(didDone), for: .touchUpInside) 61 | 62 | titleLabel.translatesAutoresizingMaskIntoConstraints = false 63 | addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .centerX, relatedBy: .equal, toItem: toolBar, attribute: .centerX, multiplier: 1, constant: 0)) 64 | addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .top, relatedBy: .equal, toItem: toolBar, attribute: .top, multiplier: 1, constant: 0)) 65 | addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .bottom, relatedBy: .equal, toItem: toolBar, attribute: .bottom, multiplier: 1, constant: 0)) 66 | titleLabel.textAlignment = .center 67 | } 68 | 69 | public required init?(coder aDecoder: NSCoder) { 70 | fatalError("init(coder:) has not been implemented") 71 | } 72 | 73 | @objc func didCancel() { 74 | onCancel?() 75 | } 76 | 77 | @objc func didDone() { 78 | // abstract method 79 | } 80 | 81 | func setTitle(title: String) { 82 | titleLabel.text = title 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /PickerController/Classes/PickerControl_Correlation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CorrelationPickerView.swift 3 | // CorrelationPicker 4 | // 5 | // Created by 王继荣 on 29/10/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class PickerControl_Correlation: PickerControl_Base { 12 | 13 | var dataSource: TreeNode 14 | var numberOfComponents: Int 15 | var onDone: ClosureDoneWithTreeNode? 16 | 17 | override var pickerView: UIView { 18 | return _pickerView 19 | } 20 | 21 | var _pickerView = UIPickerView() 22 | 23 | public convenience init(jsonStr: String) { 24 | let data = try! JSONDecoder().decode(TreeNode.self, from: jsonStr.data(using: .utf8)!) 25 | self.init(data: data) 26 | } 27 | 28 | public init(data: TreeNode) { 29 | dataSource = data 30 | numberOfComponents = dataSource.height - 1 31 | super.init(frame: CGRect.zero) 32 | 33 | _pickerView.delegate = self 34 | _pickerView.dataSource = self 35 | } 36 | 37 | public required init?(coder aDecoder: NSCoder) { 38 | fatalError("init(coder:) has not been implemented") 39 | } 40 | 41 | func setSelected(indices: [Int]) { 42 | indices.enumerated().forEach { (index, value) in 43 | _pickerView.selectRow(value, inComponent: index, animated: false) 44 | if index < numberOfComponents - 1 { 45 | _pickerView.reloadComponent(index + 1) 46 | } 47 | } 48 | } 49 | 50 | func setSelected(items: [String]) { 51 | items.enumerated().forEach { (index, item) in 52 | var nodes = dataSource.nodes 53 | if index > 0 { 54 | for i in 1...index { 55 | let selectedIndex = _pickerView.selectedRow(inComponent: i - 1) 56 | nodes = nodes?[selectedIndex].nodes 57 | } 58 | } 59 | let rows = nodes?.map({ (node) -> String in 60 | return node.value ?? "" 61 | }) 62 | if let row = rows?.index(of: item) { 63 | _pickerView.selectRow(row, inComponent: index, animated: false) 64 | if index < numberOfComponents - 1 { 65 | _pickerView.reloadComponent(index + 1) 66 | } 67 | } else { 68 | print("not valid : index -- \(index), item -- \(item)") 69 | return 70 | } 71 | } 72 | } 73 | 74 | override func didDone() { 75 | super.didDone() 76 | let indices = (0.. Int in 77 | return _pickerView.selectedRow(inComponent: index) 78 | } 79 | let items = (0.. TreeNode in 80 | var treeNodes = dataSource.nodes 81 | if index > 0 { 82 | for i in 0.. String? { 95 | var treeNodes = dataSource.nodes 96 | if component > 0 { 97 | for i in 1...component { 98 | let selectedIndex = pickerView.selectedRow(inComponent: i - 1) 99 | treeNodes = treeNodes?[selectedIndex].nodes 100 | } 101 | } 102 | return treeNodes?[row].displayName ?? treeNodes?[row].value 103 | } 104 | 105 | public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { 106 | if component < numberOfComponents - 1 { 107 | pickerView.reloadComponent(component + 1) 108 | } 109 | } 110 | } 111 | 112 | extension PickerControl_Correlation: UIPickerViewDataSource { 113 | 114 | public func numberOfComponents(in pickerView: UIPickerView) -> Int { 115 | return numberOfComponents 116 | } 117 | 118 | public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { 119 | var treeNodes = dataSource.nodes 120 | if component > 0 { 121 | for i in 1...component { 122 | let selectedIndex = pickerView.selectedRow(inComponent: i - 1) 123 | treeNodes = treeNodes?[selectedIndex].nodes 124 | } 125 | } 126 | return treeNodes?.count ?? 0 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /PickerController/Classes/PickerControl_Date.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PickerView_Date.swift 3 | // CorrelationalPicker-Example 4 | // 5 | // Created by 王继荣 on 10/11/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public typealias ClosureDateDone = (_ date: Date) -> Void 12 | 13 | public class PickerControl_Date: PickerControl_Base { 14 | 15 | var onDone: ClosureDateDone? 16 | 17 | override var pickerView: UIView { 18 | return datePicker 19 | } 20 | 21 | var datePicker = UIDatePicker() 22 | 23 | func configureDatePicker(_ configClosure: ((UIDatePicker) -> Void)?) { 24 | configClosure?(datePicker) 25 | } 26 | 27 | override func didDone() { 28 | super.didDone() 29 | onDone?(datePicker.date) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PickerController/Classes/PickerControl_Group.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CorrelationPickerView.swift 3 | // CorrelationPicker 4 | // 5 | // Created by 王继荣 on 29/10/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class PickerControl_Group: PickerControl_Base { 12 | 13 | var dataSource: [[String]] 14 | var onDone: ClosureDone? 15 | 16 | override var pickerView: UIView { 17 | return _pickerView 18 | } 19 | 20 | var _pickerView = UIPickerView() 21 | 22 | public init(data: [[String]]) { 23 | dataSource = data 24 | super.init(frame: CGRect.zero) 25 | 26 | _pickerView.delegate = self 27 | _pickerView.dataSource = self 28 | } 29 | 30 | public required init?(coder aDecoder: NSCoder) { 31 | fatalError("init(coder:) has not been implemented") 32 | } 33 | 34 | func setSelected(indices: [Int]) { 35 | indices.enumerated().forEach { (index, value) in 36 | _pickerView.selectRow(value, inComponent: index, animated: false) 37 | } 38 | } 39 | 40 | func setSelected(items: [String]) { 41 | items.enumerated().forEach { (index, item) in 42 | let row = dataSource[index].index(of: item) ?? 0 43 | _pickerView.selectRow(row, inComponent: index, animated: false) 44 | } 45 | } 46 | 47 | override func didDone() { 48 | super.didDone() 49 | let indices = (0.. Int in 50 | return _pickerView.selectedRow(inComponent: index) 51 | } 52 | let items = (0.. String in 53 | return dataSource[index][_pickerView.selectedRow(inComponent: index)] 54 | } 55 | onDone?(indices, items) 56 | } 57 | } 58 | 59 | extension PickerControl_Group: UIPickerViewDelegate { 60 | 61 | public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { 62 | return dataSource[component][row] 63 | } 64 | } 65 | 66 | extension PickerControl_Group: UIPickerViewDataSource { 67 | public func numberOfComponents(in pickerView: UIPickerView) -> Int { 68 | return dataSource.count 69 | } 70 | 71 | public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { 72 | return dataSource[component].count 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /PickerController/Classes/PickerController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PickerController.h 3 | // PickerController 4 | // 5 | // Created by 王继荣 on 13/11/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for PickerController. 12 | FOUNDATION_EXPORT double PickerControllerVersionNumber; 13 | 14 | //! Project version string for PickerController. 15 | FOUNDATION_EXPORT const unsigned char PickerControllerVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /PickerController/Classes/PickerController_Base.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WonderPicker.swift 3 | // CorrelationPicker 4 | // 5 | // Created by 王继荣 on 09/11/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class PickerController_Base: UIViewController { 12 | 13 | public var height: CGFloat = 260 14 | public var animationDuration: TimeInterval = 0.3 15 | public var backgroundAlpha: CGFloat = 0.3 16 | 17 | var pickerControl: PickerControl_Base { 18 | return PickerControl_Base() 19 | } 20 | var bottomConstraint: NSLayoutConstraint? 21 | 22 | init(title:String, onCancel: ClosureCancel? = nil) { 23 | super.init(nibName: nil, bundle: nil) 24 | setTitle(title: title) 25 | setCancelAction(onCancel) 26 | } 27 | 28 | public required init?(coder aDecoder: NSCoder) { 29 | fatalError("init(coder:) has not been implemented") 30 | } 31 | 32 | public override var preferredStatusBarStyle : UIStatusBarStyle { 33 | return .lightContent 34 | } 35 | 36 | public override func loadView() { 37 | super.loadView() 38 | 39 | view.addSubview(pickerControl) 40 | pickerControl.translatesAutoresizingMaskIntoConstraints = false 41 | view.addConstraint(NSLayoutConstraint(item: pickerControl, attribute: .leading, relatedBy: .equal, toItem: view, attribute: .leading, multiplier: 1, constant: 0)) 42 | view.addConstraint(NSLayoutConstraint(item: pickerControl, attribute: .trailing, relatedBy: .equal, toItem: view, attribute: .trailing, multiplier: 1, constant: 0)) 43 | view.addConstraint(NSLayoutConstraint(item: pickerControl, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1, constant: height)) 44 | let bottomConstraint = NSLayoutConstraint(item: pickerControl, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1, constant: height) 45 | view.addConstraint(bottomConstraint) 46 | self.bottomConstraint = bottomConstraint 47 | } 48 | 49 | public override func viewDidLoad() { 50 | super.viewDidLoad() 51 | 52 | view.backgroundColor = UIColor.black.withAlphaComponent(backgroundAlpha) 53 | pickerControl.backgroundColor = UIColor.white 54 | } 55 | 56 | public override func viewDidAppear(_ animated: Bool) { 57 | super.viewDidAppear(animated) 58 | 59 | animateToOpen() 60 | } 61 | 62 | func setTitle(title: String) { 63 | pickerControl.setTitle(title: title) 64 | } 65 | 66 | func setCancelAction(_ onCancel: ClosureCancel?) { 67 | pickerControl.onCancel = { [weak self] in 68 | self?.animateToClose { (finished) in 69 | if finished { 70 | self?.dismiss(animated: false, completion: onCancel) 71 | } 72 | } 73 | } 74 | } 75 | 76 | func animateToOpen(completion: ((Bool) -> Void)? = nil) { 77 | UIView.animate(withDuration: animationDuration, animations: { [unowned self] in 78 | self.bottomConstraint?.constant = 0 79 | self.view.setNeedsLayout() 80 | self.view.layoutIfNeeded() 81 | }, completion: completion) 82 | } 83 | 84 | func animateToClose(completion: ((Bool) -> Void)? = nil) { 85 | UIView.animate(withDuration: animationDuration, animations: { [unowned self] in 86 | self.bottomConstraint?.constant = self.height 87 | self.view.setNeedsLayout() 88 | self.view.layoutIfNeeded() 89 | }, completion: completion) 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /PickerController/Classes/PickerController_Correlation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PickerController_Correlation.swift 3 | // CorrelationPicker-Example 4 | // 5 | // Created by 王继荣 on 10/11/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class PickerController_Correlation: PickerController_Base { 12 | 13 | override var pickerControl: PickerControl_Base { 14 | return _pickerControl 15 | } 16 | 17 | var _pickerControl: PickerControl_Correlation 18 | 19 | public init(title:String, correlationalJsonStr: String, onDone: ClosureDoneWithTreeNode? = nil, onCancel: ClosureCancel? = nil) { 20 | _pickerControl = PickerControl_Correlation(jsonStr: correlationalJsonStr) 21 | super.init(title: title, onCancel: onCancel) 22 | setDoneAction(onDone) 23 | } 24 | 25 | public required init?(coder aDecoder: NSCoder) { 26 | fatalError("init(coder:) has not been implemented") 27 | } 28 | 29 | public func setSelected(items: [String]) { 30 | _pickerControl.setSelected(items: items) 31 | } 32 | 33 | public func setSelected(indices: [Int]) { 34 | _pickerControl.setSelected(indices: indices) 35 | } 36 | 37 | public func setDoneAction(_ onDone: ClosureDoneWithTreeNode?) { 38 | _pickerControl.onDone = { [weak self] (indices, items) in 39 | self?.animateToClose { (finished) in 40 | if finished { 41 | self?.dismiss(animated: false, completion: { 42 | onDone?(indices, items) 43 | }) 44 | } 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /PickerController/Classes/PickerController_Date.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PickerController_Date.swift 3 | // CorrelationalPicker-Example 4 | // 5 | // Created by 王继荣 on 10/11/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class PickerController_Date: PickerController_Base { 12 | 13 | override var pickerControl: PickerControl_Base { 14 | return _pickerControl 15 | } 16 | 17 | var _pickerControl: PickerControl_Date 18 | 19 | public init(title:String, onDone: ClosureDateDone? = nil, onCancel: ClosureCancel? = nil) { 20 | _pickerControl = PickerControl_Date() 21 | super.init(title: title, onCancel: onCancel) 22 | setDoneAction(onDone) 23 | } 24 | 25 | public required init?(coder aDecoder: NSCoder) { 26 | fatalError("init(coder:) has not been implemented") 27 | } 28 | 29 | public func configureDatePicker(_ configClosure: ((UIDatePicker) -> Void)?) { 30 | _pickerControl.configureDatePicker(configClosure) 31 | } 32 | 33 | public func setDoneAction(_ onDone: ClosureDateDone?) { 34 | _pickerControl.onDone = { [weak self] (date) in 35 | self?.animateToClose { (finished) in 36 | if finished { 37 | self?.dismiss(animated: false, completion: { 38 | onDone?(date) 39 | }) 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /PickerController/Classes/PickerController_Group.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PickerController_Group.swift 3 | // CorrelationPicker-Example 4 | // 5 | // Created by 王继荣 on 10/11/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class PickerController_Group: PickerController_Base { 12 | 13 | override var pickerControl: PickerControl_Base { 14 | return _pickerControl 15 | } 16 | 17 | var _pickerControl: PickerControl_Group 18 | 19 | public init(title:String, groupData: [[String]], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) { 20 | _pickerControl = PickerControl_Group(data: groupData) 21 | super.init(title: title, onCancel: onCancel) 22 | setDoneAction(onDone) 23 | } 24 | 25 | public required init?(coder aDecoder: NSCoder) { 26 | fatalError("init(coder:) has not been implemented") 27 | } 28 | 29 | public func setSelected(items: [String]) { 30 | _pickerControl.setSelected(items: items) 31 | } 32 | 33 | public func setSelected(indices: [Int]) { 34 | _pickerControl.setSelected(indices: indices) 35 | } 36 | 37 | public func setDoneAction(_ onDone: ClosureDone?) { 38 | _pickerControl.onDone = { [weak self] (indices, items) in 39 | self?.animateToClose { (finished) in 40 | if finished { 41 | self?.dismiss(animated: false, completion: { 42 | onDone?(indices, items) 43 | }) 44 | } 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /PickerController/Classes/Tree+Height.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Tree+Extensible.swift 3 | // CorrelationPicker 4 | // 5 | // Created by 王继荣 on 08/11/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | extension TreeNode { 10 | public var height: Int { 11 | return getTreeHeight(treeNode: self) 12 | } 13 | 14 | private func getTreeHeight(treeNode: TreeNode) -> Int { 15 | return treeNode.nodes?.isEmpty ?? true ? { 16 | return 1 17 | }() : { 18 | return (treeNode.nodes?.map({ (treeNode) -> Int in 19 | return getTreeHeight(treeNode: treeNode) 20 | }).max() ?? 0) + 1 21 | }() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /PickerController/Classes/Tree.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct TreeNode: Codable { 4 | 5 | public let nodes: [TreeNode]? 6 | public let value: String? 7 | public let displayName: String? 8 | 9 | } 10 | 11 | extension TreeNode: CustomStringConvertible { 12 | public var description: String { 13 | return displayName ?? value ?? "" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /PickerController/Classes/UIViewController+ShowPicker.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+ShowPicker.swift 3 | // CorrelationPicker 4 | // 5 | // Created by 王继荣 on 09/11/2016. 6 | // Copyright © 2016 snowflyer. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIViewController { 12 | 13 | func showPicker(pickerController: PickerController_Base, completion: (() -> Void)? = nil) { 14 | pickerController.modalPresentationStyle = .overCurrentContext 15 | present(pickerController, animated: false, completion: completion) 16 | } 17 | } 18 | 19 | extension UIViewController { 20 | 21 | public func showCorrelationPicker(title:String, correlationalJsonStr: String, selectedItems: [String], onDone: ClosureDoneWithTreeNode? = nil, onCancel: ClosureCancel? = nil) { 22 | let pickerController = PickerController_Correlation(title: title, correlationalJsonStr: correlationalJsonStr, onDone: onDone, onCancel: onCancel) 23 | showPicker(pickerController: pickerController) { 24 | pickerController.setSelected(items: selectedItems) 25 | } 26 | } 27 | 28 | public func showCorrelationPicker(title:String, correlationalJsonStr: String, selectedIndices: [Int], onDone: ClosureDoneWithTreeNode? = nil, onCancel: ClosureCancel? = nil) { 29 | let pickerController = PickerController_Correlation(title: title, correlationalJsonStr: correlationalJsonStr, onDone: onDone, onCancel: onCancel) 30 | showPicker(pickerController: pickerController) { 31 | pickerController.setSelected(indices: selectedIndices) 32 | } 33 | } 34 | 35 | public func showCorrelationPicker(title:String, correlationalJsonFile: String, selectedItems: [String], onDone: ClosureDoneWithTreeNode? = nil, onCancel: ClosureCancel? = nil) { 36 | do { 37 | let correlationalJsonStr = try String(contentsOfFile: correlationalJsonFile) 38 | showCorrelationPicker(title: title, correlationalJsonStr: correlationalJsonStr, selectedItems: selectedItems, onDone: onDone, onCancel: onCancel) 39 | } catch { 40 | print(error.localizedDescription) 41 | } 42 | } 43 | 44 | public func showCorrelationPicker(title:String, correlationalJsonFile: String, selectedIndices: [Int], onDone: ClosureDoneWithTreeNode? = nil, onCancel: ClosureCancel? = nil) { 45 | do { 46 | let correlationalJsonStr = try String(contentsOfFile: correlationalJsonFile) 47 | showCorrelationPicker(title: title, correlationalJsonStr: correlationalJsonStr, selectedIndices: selectedIndices, onDone: onDone, onCancel: onCancel) 48 | } catch { 49 | print(error.localizedDescription) 50 | } 51 | } 52 | 53 | public func showGroupPicker(title:String, groupData: [[String]], selectedItems: [String], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) { 54 | let pickerController = PickerController_Group(title: title, groupData: groupData, onDone: onDone, onCancel: onCancel) 55 | showPicker(pickerController: pickerController) { 56 | pickerController.setSelected(items: selectedItems) 57 | } 58 | } 59 | 60 | public func showGroupPicker(title:String, groupData: [[String]], selectedIndices: [Int], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) { 61 | let pickerController = PickerController_Group(title: title, groupData: groupData, onDone: onDone, onCancel: onCancel) 62 | showPicker(pickerController: pickerController) { 63 | pickerController.setSelected(indices: selectedIndices) 64 | } 65 | } 66 | 67 | public func showDatePicker(title: String, onConfigure: ((UIDatePicker) -> Void)? = nil, onDone: ClosureDateDone? = nil, onCancel: ClosureCancel? = nil) { 68 | let pickerController = PickerController_Date(title: title, onDone: onDone, onCancel: onCancel) 69 | showPicker(pickerController: pickerController) { 70 | pickerController._pickerControl.configureDatePicker(onConfigure) 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PickerController 2 | 3 | [![CI Status](http://img.shields.io/travis/wonderbear/PickerController.svg?style=flat)](https://travis-ci.org/wonderbear/PickerController) [![Version](https://img.shields.io/cocoapods/v/PickerController.svg?style=flat)](http://cocoapods.org/pods/PickerController) [![Platform](https://img.shields.io/cocoapods/p/PickerController.svg?style=flat)](http://cocoapods.org/pods/PickerController) 4 | [![Swift 4.2](https://img.shields.io/badge/Swift-4.2-orange.svg?style=flat)](https://developer.apple.com/swift/) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![License](https://img.shields.io/cocoapods/l/PickerController.svg?style=flat)](http://cocoapods.org/pods/PickerController) 5 | 6 | PickerController, can make correlational pick. I love it. 7 | 8 | ![PickerController](/ScreenShot/PickerController.gif "PickerController") 9 | 10 | ## Contents 11 | 12 | - [Features](#features) 13 | - [Requirements](#requirements) 14 | - [Example](#example) 15 | - [Installation](#installation) 16 | - [Usage](#usage) 17 | - [Properties](#properties) 18 | - [Author](#author) 19 | - [License](#license) 20 | 21 | ## Features 22 | 23 | - [x] Correlational picker support 24 | - [x] Group picker support 25 | - [x] Date picker support 26 | 27 | ## Requirements 28 | 29 | - iOS 8.0+ / Mac OS X 10.11+ / tvOS 9.0+ 30 | - Xcode 8.0+ 31 | - Swift 4.2+ 32 | 33 | ## Installation 34 | 35 | ### CocoaPods 36 | 37 | [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: 38 | 39 | ```bash 40 | $ gem install cocoapods 41 | ``` 42 | 43 | To integrate PickerController into your Xcode project using CocoaPods, specify it in your `Podfile`: 44 | 45 | ```ruby 46 | source 'https://github.com/CocoaPods/Specs.git' 47 | platform :ios, '8.0' 48 | use_frameworks! 49 | 50 | target '' do 51 | pod 'PickerController', '~> 0.1.0' 52 | end 53 | ``` 54 | 55 | Then, run the following command: 56 | 57 | ```bash 58 | $ pod install 59 | ``` 60 | 61 | ### Carthage 62 | 63 | [Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. 64 | 65 | You can install Carthage with [Homebrew](http://brew.sh/) using the following command: 66 | 67 | ```bash 68 | $ brew update 69 | $ brew install carthage 70 | ``` 71 | 72 | To integrate PickerController into your Xcode project using Carthage, specify it in your `Cartfile`: 73 | 74 | ```ogdl 75 | github "xiongxiong/PickerController" ~> 0.1.0 76 | ``` 77 | 78 | Run `carthage update` to build the framework and drag the built `PickerController.framework` and `SwiftyJSON.framework` into your Xcode project. 79 | 80 | ### Manually 81 | 82 | If you prefer not to use either of the aforementioned dependency managers, you can integrate PickerController into your project manually. 83 | 84 | ## Example 85 | 86 | Open the example project, build and run. 87 | 88 | ## Usage 89 | 90 | ### Extension of UIViewController 91 | ```swift 92 | extension UIViewController { 93 | 94 | public func showCorrelationPicker(title:String, correlationalJsonStr: String, selectedItems: [String], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) { 95 | ... 96 | } 97 | 98 | public func showCorrelationPicker(title:String, correlationalJsonStr: String, selectedIndices: [Int], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) { 99 | ... 100 | } 101 | 102 | public func showCorrelationPicker(title:String, correlationalJsonFile: String, selectedItems: [String], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) { 103 | ... 104 | } 105 | 106 | public func showCorrelationPicker(title:String, correlationalJsonFile: String, selectedIndices: [Int], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) { 107 | ... 108 | } 109 | 110 | public func showGroupPicker(title:String, groupData: [[String]], selectedItems: [String], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) { 111 | ... 112 | } 113 | 114 | public func showGroupPicker(title:String, groupData: [[String]], selectedIndices: [Int], onDone: ClosureDone? = nil, onCancel: ClosureCancel? = nil) { 115 | ... 116 | } 117 | 118 | public func showDatePicker(title: String, initialDate: Date, onDone: ClosureDateDone? = nil, onCancel: ClosureCancel? = nil) { 119 | ... 120 | } 121 | } 122 | ``` 123 | 124 | ### Use PickerController 125 | 126 | ```swift 127 | func onClicked_button1() { 128 | let data = [["1983", "1984", "1985"], ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]] 129 | showGroupPicker(title: "Hello", groupData: data, selectedItems: ["1984", "6月"], onDone: { [unowned self] (indices, items) in 130 | self.labelIndices.text = "indices -- \(indices)" 131 | self.labelItems.text = "items -- \(items)" 132 | }, onCancel: { 133 | self.labelIndices.text = "selected nothing" 134 | self.labelItems.text = "selected nothing" 135 | }) 136 | } 137 | 138 | func onClicked_button3() { 139 | showDatePicker(title: "时间", initialDate: Date(), onDone: { [unowned self] (date) in 140 | self.labelIndices.text = "" 141 | self.labelItems.text = "date -- \(date)" 142 | }, onCancel: { 143 | self.labelIndices.text = "" 144 | self.labelItems.text = "selected nothing" 145 | }) 146 | } 147 | ``` 148 | 149 | ## Properties 150 | 151 | - height: CGFloat // height of picker in PickerController 152 | - animationDuration: TimeInterval // animation duration of picker 153 | - backgroundAlpha: CGFloat // background alpha of PickerController 154 | 155 | ## Author 156 | 157 | xiongxiong, ximengwuheng@163.com 158 | 159 | ## License 160 | 161 | PickerController is available under the MIT license. See the LICENSE file for more info. 162 | -------------------------------------------------------------------------------- /ScreenShot/PickerController.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongxiong/PickerController/15b27a76965d554a4614bf707f1d5c46471de673/ScreenShot/PickerController.gif -------------------------------------------------------------------------------- /ScreenShot/Simulator Screen Shot 25 Nov 2016, 4.54.07 PM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongxiong/PickerController/15b27a76965d554a4614bf707f1d5c46471de673/ScreenShot/Simulator Screen Shot 25 Nov 2016, 4.54.07 PM.png -------------------------------------------------------------------------------- /ScreenShot/Simulator Screen Shot 25 Nov 2016, 4.54.07 PM_result1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiongxiong/PickerController/15b27a76965d554a4614bf707f1d5c46471de673/ScreenShot/Simulator Screen Shot 25 Nov 2016, 4.54.07 PM_result1.jpg -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj --------------------------------------------------------------------------------