diff --git a/CFCityPickerVC.xcodeproj/project.pbxproj b/CFCityPickerVC.xcodeproj/project.pbxproj new file mode 100644 index 0000000..162ec15 --- /dev/null +++ b/CFCityPickerVC.xcodeproj/project.pbxproj @@ -0,0 +1,522 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 89D7D6A81B69AB16005C2273 /* CityModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89D7D6A71B69AB16005C2273 /* CityModel.swift */; }; + 89D7D6AB1B69B728005C2273 /* CFCityPickerVC+Main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89D7D6AA1B69B728005C2273 /* CFCityPickerVC+Main.swift */; }; + 89D7D6AD1B69B748005C2273 /* CFCityPickerVC+TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89D7D6AC1B69B748005C2273 /* CFCityPickerVC+TableView.swift */; }; + 89D7D6B31B69BA0D005C2273 /* img.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 89D7D6B21B69BA0D005C2273 /* img.bundle */; }; + 89D7D6B61B69BC7F005C2273 /* CFCityCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89D7D6B41B69BC7F005C2273 /* CFCityCell.swift */; }; + 89D7D6B71B69BC7F005C2273 /* CFCityCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89D7D6B51B69BC7F005C2273 /* CFCityCell.xib */; }; + 89D7D6BA1B69CDCF005C2273 /* CFCityPickerVCCommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89D7D6B91B69CDCF005C2273 /* CFCityPickerVCCommon.swift */; }; + 89D7D6BC1B69EB06005C2273 /* HeaderItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89D7D6BB1B69EB06005C2273 /* HeaderItemView.swift */; }; + 89D7D6BE1B69ECB5005C2273 /* HeaderItemView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89D7D6BD1B69ECB5005C2273 /* HeaderItemView.xib */; }; + 89F162441B68D4B8005556C3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89F162431B68D4B8005556C3 /* AppDelegate.swift */; }; + 89F162461B68D4B8005556C3 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89F162451B68D4B8005556C3 /* ViewController.swift */; }; + 89F162491B68D4B8005556C3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 89F162471B68D4B8005556C3 /* Main.storyboard */; }; + 89F1624B1B68D4B8005556C3 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 89F1624A1B68D4B8005556C3 /* Images.xcassets */; }; + 89F1624E1B68D4B8005556C3 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89F1624C1B68D4B8005556C3 /* LaunchScreen.xib */; }; + 89F1625A1B68D4B8005556C3 /* CFCityPickerVCTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89F162591B68D4B8005556C3 /* CFCityPickerVCTests.swift */; }; + 89F162651B68D627005556C3 /* CFCityPickerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89F162641B68D627005556C3 /* CFCityPickerVC.swift */; }; + 89FC52F31B68D926009E7A0D /* City.plist in Resources */ = {isa = PBXBuildFile; fileRef = 89FC52F21B68D926009E7A0D /* City.plist */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 89F162541B68D4B8005556C3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 89F162361B68D4B7005556C3 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 89F1623D1B68D4B8005556C3; + remoteInfo = CFCityPickerVC; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 89D7D6A71B69AB16005C2273 /* CityModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CityModel.swift; sourceTree = ""; }; + 89D7D6AA1B69B728005C2273 /* CFCityPickerVC+Main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CFCityPickerVC+Main.swift"; sourceTree = ""; }; + 89D7D6AC1B69B748005C2273 /* CFCityPickerVC+TableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CFCityPickerVC+TableView.swift"; sourceTree = ""; }; + 89D7D6B21B69BA0D005C2273 /* img.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = img.bundle; sourceTree = ""; }; + 89D7D6B41B69BC7F005C2273 /* CFCityCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CFCityCell.swift; sourceTree = ""; }; + 89D7D6B51B69BC7F005C2273 /* CFCityCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CFCityCell.xib; sourceTree = ""; }; + 89D7D6B91B69CDCF005C2273 /* CFCityPickerVCCommon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CFCityPickerVCCommon.swift; sourceTree = ""; }; + 89D7D6BB1B69EB06005C2273 /* HeaderItemView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderItemView.swift; sourceTree = ""; }; + 89D7D6BD1B69ECB5005C2273 /* HeaderItemView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HeaderItemView.xib; sourceTree = ""; }; + 89F1623E1B68D4B8005556C3 /* CFCityPickerVC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CFCityPickerVC.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 89F162421B68D4B8005556C3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 89F162431B68D4B8005556C3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 89F162451B68D4B8005556C3 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 89F162481B68D4B8005556C3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 89F1624A1B68D4B8005556C3 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 89F1624D1B68D4B8005556C3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; + 89F162531B68D4B8005556C3 /* CFCityPickerVCTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CFCityPickerVCTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 89F162581B68D4B8005556C3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 89F162591B68D4B8005556C3 /* CFCityPickerVCTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CFCityPickerVCTests.swift; sourceTree = ""; }; + 89F162641B68D627005556C3 /* CFCityPickerVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CFCityPickerVC.swift; sourceTree = ""; }; + 89FC52F21B68D926009E7A0D /* City.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = City.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 89F1623B1B68D4B8005556C3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 89F162501B68D4B8005556C3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 89D7D6A51B69AAEB005C2273 /* Model */ = { + isa = PBXGroup; + children = ( + 89D7D6A71B69AB16005C2273 /* CityModel.swift */, + ); + path = Model; + sourceTree = ""; + }; + 89D7D6A61B69AAEB005C2273 /* View */ = { + isa = PBXGroup; + children = ( + 89D7D6B41B69BC7F005C2273 /* CFCityCell.swift */, + 89D7D6B51B69BC7F005C2273 /* CFCityCell.xib */, + 89D7D6BB1B69EB06005C2273 /* HeaderItemView.swift */, + 89D7D6BD1B69ECB5005C2273 /* HeaderItemView.xib */, + ); + path = View; + sourceTree = ""; + }; + 89D7D6A91B69B719005C2273 /* Extendsion */ = { + isa = PBXGroup; + children = ( + 89D7D6AA1B69B728005C2273 /* CFCityPickerVC+Main.swift */, + 89D7D6AC1B69B748005C2273 /* CFCityPickerVC+TableView.swift */, + ); + path = Extendsion; + sourceTree = ""; + }; + 89D7D6B11B69BA0D005C2273 /* Resource */ = { + isa = PBXGroup; + children = ( + 89D7D6B21B69BA0D005C2273 /* img.bundle */, + ); + path = Resource; + sourceTree = ""; + }; + 89D7D6B81B69CDBD005C2273 /* Common */ = { + isa = PBXGroup; + children = ( + 89D7D6B91B69CDCF005C2273 /* CFCityPickerVCCommon.swift */, + ); + path = Common; + sourceTree = ""; + }; + 89F162351B68D4B7005556C3 = { + isa = PBXGroup; + children = ( + 89F162401B68D4B8005556C3 /* CFCityPickerVC */, + 89F162561B68D4B8005556C3 /* CFCityPickerVCTests */, + 89F1623F1B68D4B8005556C3 /* Products */, + ); + sourceTree = ""; + }; + 89F1623F1B68D4B8005556C3 /* Products */ = { + isa = PBXGroup; + children = ( + 89F1623E1B68D4B8005556C3 /* CFCityPickerVC.app */, + 89F162531B68D4B8005556C3 /* CFCityPickerVCTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 89F162401B68D4B8005556C3 /* CFCityPickerVC */ = { + isa = PBXGroup; + children = ( + 89F162631B68D60D005556C3 /* CFCityPickerVC */, + 89F162431B68D4B8005556C3 /* AppDelegate.swift */, + 89F162451B68D4B8005556C3 /* ViewController.swift */, + 89F162471B68D4B8005556C3 /* Main.storyboard */, + 89F1624A1B68D4B8005556C3 /* Images.xcassets */, + 89F1624C1B68D4B8005556C3 /* LaunchScreen.xib */, + 89F162411B68D4B8005556C3 /* Supporting Files */, + ); + path = CFCityPickerVC; + sourceTree = ""; + }; + 89F162411B68D4B8005556C3 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 89FC52F21B68D926009E7A0D /* City.plist */, + 89F162421B68D4B8005556C3 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 89F162561B68D4B8005556C3 /* CFCityPickerVCTests */ = { + isa = PBXGroup; + children = ( + 89F162591B68D4B8005556C3 /* CFCityPickerVCTests.swift */, + 89F162571B68D4B8005556C3 /* Supporting Files */, + ); + path = CFCityPickerVCTests; + sourceTree = ""; + }; + 89F162571B68D4B8005556C3 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 89F162581B68D4B8005556C3 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 89F162631B68D60D005556C3 /* CFCityPickerVC */ = { + isa = PBXGroup; + children = ( + 89F162641B68D627005556C3 /* CFCityPickerVC.swift */, + 89D7D6A51B69AAEB005C2273 /* Model */, + 89D7D6A61B69AAEB005C2273 /* View */, + 89D7D6A91B69B719005C2273 /* Extendsion */, + 89D7D6B11B69BA0D005C2273 /* Resource */, + 89D7D6B81B69CDBD005C2273 /* Common */, + ); + path = CFCityPickerVC; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 89F1623D1B68D4B8005556C3 /* CFCityPickerVC */ = { + isa = PBXNativeTarget; + buildConfigurationList = 89F1625D1B68D4B8005556C3 /* Build configuration list for PBXNativeTarget "CFCityPickerVC" */; + buildPhases = ( + 89F1623A1B68D4B8005556C3 /* Sources */, + 89F1623B1B68D4B8005556C3 /* Frameworks */, + 89F1623C1B68D4B8005556C3 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CFCityPickerVC; + productName = CFCityPickerVC; + productReference = 89F1623E1B68D4B8005556C3 /* CFCityPickerVC.app */; + productType = "com.apple.product-type.application"; + }; + 89F162521B68D4B8005556C3 /* CFCityPickerVCTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 89F162601B68D4B8005556C3 /* Build configuration list for PBXNativeTarget "CFCityPickerVCTests" */; + buildPhases = ( + 89F1624F1B68D4B8005556C3 /* Sources */, + 89F162501B68D4B8005556C3 /* Frameworks */, + 89F162511B68D4B8005556C3 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 89F162551B68D4B8005556C3 /* PBXTargetDependency */, + ); + name = CFCityPickerVCTests; + productName = CFCityPickerVCTests; + productReference = 89F162531B68D4B8005556C3 /* CFCityPickerVCTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 89F162361B68D4B7005556C3 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0630; + ORGANIZATIONNAME = "冯成林"; + TargetAttributes = { + 89F1623D1B68D4B8005556C3 = { + CreatedOnToolsVersion = 6.3.1; + }; + 89F162521B68D4B8005556C3 = { + CreatedOnToolsVersion = 6.3.1; + TestTargetID = 89F1623D1B68D4B8005556C3; + }; + }; + }; + buildConfigurationList = 89F162391B68D4B7005556C3 /* Build configuration list for PBXProject "CFCityPickerVC" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 89F162351B68D4B7005556C3; + productRefGroup = 89F1623F1B68D4B8005556C3 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 89F1623D1B68D4B8005556C3 /* CFCityPickerVC */, + 89F162521B68D4B8005556C3 /* CFCityPickerVCTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 89F1623C1B68D4B8005556C3 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 89F162491B68D4B8005556C3 /* Main.storyboard in Resources */, + 89D7D6B31B69BA0D005C2273 /* img.bundle in Resources */, + 89D7D6BE1B69ECB5005C2273 /* HeaderItemView.xib in Resources */, + 89FC52F31B68D926009E7A0D /* City.plist in Resources */, + 89D7D6B71B69BC7F005C2273 /* CFCityCell.xib in Resources */, + 89F1624E1B68D4B8005556C3 /* LaunchScreen.xib in Resources */, + 89F1624B1B68D4B8005556C3 /* Images.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 89F162511B68D4B8005556C3 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 89F1623A1B68D4B8005556C3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 89D7D6AD1B69B748005C2273 /* CFCityPickerVC+TableView.swift in Sources */, + 89D7D6A81B69AB16005C2273 /* CityModel.swift in Sources */, + 89F162461B68D4B8005556C3 /* ViewController.swift in Sources */, + 89D7D6BA1B69CDCF005C2273 /* CFCityPickerVCCommon.swift in Sources */, + 89F162651B68D627005556C3 /* CFCityPickerVC.swift in Sources */, + 89D7D6B61B69BC7F005C2273 /* CFCityCell.swift in Sources */, + 89F162441B68D4B8005556C3 /* AppDelegate.swift in Sources */, + 89D7D6AB1B69B728005C2273 /* CFCityPickerVC+Main.swift in Sources */, + 89D7D6BC1B69EB06005C2273 /* HeaderItemView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 89F1624F1B68D4B8005556C3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 89F1625A1B68D4B8005556C3 /* CFCityPickerVCTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 89F162551B68D4B8005556C3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 89F1623D1B68D4B8005556C3 /* CFCityPickerVC */; + targetProxy = 89F162541B68D4B8005556C3 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 89F162471B68D4B8005556C3 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 89F162481B68D4B8005556C3 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 89F1624C1B68D4B8005556C3 /* LaunchScreen.xib */ = { + isa = PBXVariantGroup; + children = ( + 89F1624D1B68D4B8005556C3 /* Base */, + ); + name = LaunchScreen.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 89F1625B1B68D4B8005556C3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 89F1625C1B68D4B8005556C3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 89F1625E1B68D4B8005556C3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + INFOPLIST_FILE = CFCityPickerVC/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 89F1625F1B68D4B8005556C3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + INFOPLIST_FILE = CFCityPickerVC/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 89F162611B68D4B8005556C3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = CFCityPickerVCTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CFCityPickerVC.app/CFCityPickerVC"; + }; + name = Debug; + }; + 89F162621B68D4B8005556C3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + INFOPLIST_FILE = CFCityPickerVCTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CFCityPickerVC.app/CFCityPickerVC"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 89F162391B68D4B7005556C3 /* Build configuration list for PBXProject "CFCityPickerVC" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 89F1625B1B68D4B8005556C3 /* Debug */, + 89F1625C1B68D4B8005556C3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 89F1625D1B68D4B8005556C3 /* Build configuration list for PBXNativeTarget "CFCityPickerVC" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 89F1625E1B68D4B8005556C3 /* Debug */, + 89F1625F1B68D4B8005556C3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 89F162601B68D4B8005556C3 /* Build configuration list for PBXNativeTarget "CFCityPickerVCTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 89F162611B68D4B8005556C3 /* Debug */, + 89F162621B68D4B8005556C3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 89F162361B68D4B7005556C3 /* Project object */; +} diff --git a/CFCityPickerVC.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/CFCityPickerVC.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..f3e37b7 --- /dev/null +++ b/CFCityPickerVC.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/CFCityPickerVC.xcodeproj/project.xcworkspace/xcuserdata/Charlin.xcuserdatad/UserInterfaceState.xcuserstate b/CFCityPickerVC.xcodeproj/project.xcworkspace/xcuserdata/Charlin.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..db208b5 Binary files /dev/null and b/CFCityPickerVC.xcodeproj/project.xcworkspace/xcuserdata/Charlin.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CFCityPickerVC.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/CFCityPickerVC.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/CFCityPickerVC.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/CFCityPickerVC.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcschemes/CFCityPickerVC.xcscheme b/CFCityPickerVC.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcschemes/CFCityPickerVC.xcscheme new file mode 100644 index 0000000..2416fdc --- /dev/null +++ b/CFCityPickerVC.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcschemes/CFCityPickerVC.xcscheme @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CFCityPickerVC.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcschemes/xcschememanagement.plist b/CFCityPickerVC.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..cca893a --- /dev/null +++ b/CFCityPickerVC.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,27 @@ + + + + + SchemeUserState + + CFCityPickerVC.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 89F1623D1B68D4B8005556C3 + + primary + + + 89F162521B68D4B8005556C3 + + primary + + + + + diff --git a/CFCityPickerVC/AppDelegate.swift b/CFCityPickerVC/AppDelegate.swift new file mode 100644 index 0000000..a84ecce --- /dev/null +++ b/CFCityPickerVC/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// CFCityPickerVC +// +// Created by 冯成林 on 15/7/29. +// Copyright (c) 2015年 冯成林. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(application: UIApplication) { + // 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. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(application: UIApplication) { + // 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. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(application: UIApplication) { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(application: UIApplication) { + // 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. + } + + func applicationWillTerminate(application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/CFCityPickerVC/Base.lproj/LaunchScreen.xib b/CFCityPickerVC/Base.lproj/LaunchScreen.xib new file mode 100644 index 0000000..f09696b --- /dev/null +++ b/CFCityPickerVC/Base.lproj/LaunchScreen.xib @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CFCityPickerVC/Base.lproj/Main.storyboard b/CFCityPickerVC/Base.lproj/Main.storyboard new file mode 100644 index 0000000..73dc2b0 --- /dev/null +++ b/CFCityPickerVC/Base.lproj/Main.storyboard @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CFCityPickerVC/CFCityPickerVC/CFCityPickerVC.swift b/CFCityPickerVC/CFCityPickerVC/CFCityPickerVC.swift new file mode 100644 index 0000000..58071a7 --- /dev/null +++ b/CFCityPickerVC/CFCityPickerVC/CFCityPickerVC.swift @@ -0,0 +1,44 @@ +// +// CFCityPickerVC.swift +// CFCityPickerVC +// +// Created by 冯成林 on 15/7/29. +// Copyright (c) 2015年 冯成林. All rights reserved. +// + +import UIKit + +class CFCityPickerVC: UITableViewController { + + var cityModels: [CityModel]! + + let cityPVCTintColor = UIColor.grayColor() + + /** 可设置:当前城市 */ + var currentCity: String! + + /** 可设置:热门城市 */ + var hotCities: [String]! + + + lazy var indexTitleLabel: UILabel = {UILabel()}() + + var showTime: CGFloat = 1.0 + + var indexTitleIndexArray: [Int] = [] + + var selectedCityModel: ((cityModel: CityModel) -> Void)! + + lazy var dismissBtn: UIButton = { UIButton(frame: CGRectMake(0, 0, 24, 24)) }() + + lazy var selectedCityArray: [String] = {NSUserDefaults.standardUserDefaults().objectForKey(SelectedCityKey) as? [String] ?? []}() + +} + + +extension CFCityPickerVC{ + + class func getInstance() -> CFCityPickerVC{ + return CFCityPickerVC(style: UITableViewStyle.Plain) + } +} \ No newline at end of file diff --git a/CFCityPickerVC/CFCityPickerVC/Common/CFCityPickerVCCommon.swift b/CFCityPickerVC/CFCityPickerVC/Common/CFCityPickerVCCommon.swift new file mode 100644 index 0000000..20d7a7a --- /dev/null +++ b/CFCityPickerVC/CFCityPickerVC/Common/CFCityPickerVCCommon.swift @@ -0,0 +1,27 @@ +// +// CFCommon.swift +// CFCityPickerVC +// +// Created by 冯成林 on 15/7/30. +// Copyright (c) 2015年 冯成林. All rights reserved. +// + +import Foundation +import UIKit + +/** 通知 */ +let CityChoosedNoti = "CityChoosedNoti" + +/** 归档key */ +let SelectedCityKey = "SelectedCityKey" + +extension CFCityPickerVC{ + + class func rgba(r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) -> UIColor{ + + return UIColor(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: a) + } + + +} + diff --git a/CFCityPickerVC/CFCityPickerVC/Extendsion/CFCityPickerVC+Main.swift b/CFCityPickerVC/CFCityPickerVC/Extendsion/CFCityPickerVC+Main.swift new file mode 100644 index 0000000..032585f --- /dev/null +++ b/CFCityPickerVC/CFCityPickerVC/Extendsion/CFCityPickerVC+Main.swift @@ -0,0 +1,37 @@ +// +// CFCityPickerVC+Main.swift +// CFCityPickerVC +// +// Created by 冯成林 on 15/7/30. +// Copyright (c) 2015年 冯成林. All rights reserved. +// + +import Foundation +import UIKit + + +extension CFCityPickerVC { + + override func viewDidLoad() { + + super.viewDidLoad() + + /** 返回按钮 */ + dismissBtnPrepare() + + /** 为tableView准备 */ + tableViewPrepare() + } + + /** 返回按钮 */ + func dismissBtnPrepare(){ + + dismissBtn.setImage(UIImage(named: "img.bundle/cancel"), forState: UIControlState.Normal) + dismissBtn.addTarget(self, action: "dismiss", forControlEvents: UIControlEvents.TouchUpInside) + self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: dismissBtn) + } + + func dismiss(){ + self.dismissViewControllerAnimated(true, completion: nil) + } +} \ No newline at end of file diff --git a/CFCityPickerVC/CFCityPickerVC/Extendsion/CFCityPickerVC+TableView.swift b/CFCityPickerVC/CFCityPickerVC/Extendsion/CFCityPickerVC+TableView.swift new file mode 100644 index 0000000..aeea9d0 --- /dev/null +++ b/CFCityPickerVC/CFCityPickerVC/Extendsion/CFCityPickerVC+TableView.swift @@ -0,0 +1,292 @@ +// +// CFCityPickerVC+TableView.swift +// CFCityPickerVC +// +// Created by 冯成林 on 15/7/30. +// Copyright (c) 2015年 冯成林. All rights reserved. +// + +import Foundation +import UIKit + +extension CFCityPickerVC{ + + var currentCityModel: CityModel? {if self.currentCity==nil{return nil};return CityModel.findCityModelWithCityName([self.currentCity], cityModels: self.cityModels)?.first} + var hotCityModels: [CityModel]? {if self.hotCities==nil{return nil};return CityModel.findCityModelWithCityName(self.hotCities, cityModels: self.cityModels)} + var historyModels: [CityModel]? {if self.selectedCityArray.count == 0 {return nil};return CityModel.findCityModelWithCityName(self.selectedCityArray, cityModels: self.cityModels)} + + var headViewWith: CGFloat{return UIScreen.mainScreen().bounds.width - 10} + + + var sortedCityModles: [CityModel] { + + return cityModels.sorted({ (m1, m2) -> Bool in + m1.getFirstUpperLetter < m2.getFirstUpperLetter + }) + } + + + /** 计算高度 */ + func headItemViewH(count: Int) -> CGRect{ + var height: CGFloat = count < 4 ? 90 : 140 + return CGRectMake(0, 0, headViewWith, height) + } + + + /** 为tableView准备 */ + func tableViewPrepare(){ + + self.title = "城市选择" + + /** 处理label */ + labelPrepare() + + self.tableView.sectionIndexColor = cityPVCTintColor + + /** headerView */ + headerviewPrepare() + + /** 定位处理 */ + locationPrepare() + + //通知处理 + NSNotificationCenter.defaultCenter().addObserver(self, selector: "notiAction:", name: CityChoosedNoti, object: nil) + + println(self.selectedCityArray) + } + + + func notiAction(noti: NSNotification){ + + let userInfo = noti.userInfo as! [String: CityModel] + let cityModel = userInfo["citiModel"]! + citySelected(cityModel) + } + + + + + + /** 定位处理 */ + func locationPrepare(){ + + if self.currentCity != nil {return} + + //定位开始 + } + + + + /** headerView */ + func headerviewPrepare(){ + + let headerView = UIView() + headerView.frame = CGRectMake(0, 0, headViewWith, 420) + + + + let itemView = HeaderItemView.getHeaderItemView("当前城市") + var currentCities: [CityModel] = [] + if self.currentCityModel != nil {currentCities.append(self.currentCityModel!)} + itemView.cityModles = currentCities + var frame1 = headItemViewH(itemView.cityModles.count) + frame1.origin.y = 20 + itemView.frame = frame1 + headerView.addSubview(itemView) + + + let itemView2 = HeaderItemView.getHeaderItemView("历史选择") + var historyCityModels: [CityModel] = [] + if self.historyModels != nil {historyCityModels += self.historyModels!} + itemView2.cityModles = historyCityModels + var frame2 = headItemViewH(itemView2.cityModles.count) + frame2.origin.y = CGRectGetMaxY(frame1) + itemView2.frame = frame2 + headerView.addSubview(itemView2) + + + + let itemView3 = HeaderItemView.getHeaderItemView("热门城市") + var hotCityModels: [CityModel] = [] + if self.hotCityModels != nil {hotCityModels += self.hotCityModels!} + itemView3.cityModles = hotCityModels + var frame3 = headItemViewH(itemView3.cityModles.count) + frame3.origin.y = CGRectGetMaxY(frame2) + itemView3.frame = frame3 + headerView.addSubview(itemView3) + + + self.tableView.tableHeaderView = headerView + } + + + + + + + + + + /** 处理label */ + func labelPrepare(){ + + indexTitleLabel.backgroundColor = CFCityPickerVC.rgba(0, g: 0, b: 0, a: 0.4) + indexTitleLabel.center = self.view.center + indexTitleLabel.bounds = CGRectMake(0, 0, 120, 100) + indexTitleLabel.font = UIFont.boldSystemFontOfSize(80) + indexTitleLabel.textAlignment = NSTextAlignment.Center + indexTitleLabel.textColor = UIColor.whiteColor() + } + + + override func numberOfSectionsInTableView(tableView: UITableView) -> Int { + return sortedCityModles.count + } + + override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + + let children = sortedCityModles[section].children + + return children==nil ? 0 : children!.count + } + + + override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + + return sortedCityModles[section].name + + } + + override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + + let cell = CFCityCell.cityCellInTableView(tableView) + + cell.cityModel = sortedCityModles[indexPath.section].children?[indexPath.item] + + return cell + } + + override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + + tableView.deselectRowAtIndexPath(indexPath, animated: true) + + let cityModel = sortedCityModles[indexPath.section].children![indexPath.row] + citySelected(cityModel) + } + + override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + + return 44 + } + + override func sectionIndexTitlesForTableView(tableView: UITableView) -> [AnyObject]! { + return indexHandle() + } + + override func tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int { + + showIndexTitle(title) + + self.showTime = 1 + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW,Int64(0.2 * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), {[unowned self] () -> Void in + + self.showTime = 0.8 + + }) + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW,Int64(0.4 * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), {[unowned self] () -> Void in + + if self.showTime == 0.8 { + + self.showTime = 0.6 + } + }) + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW,Int64(0.6 * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), {[unowned self] () -> Void in + + + if self.showTime == 0.6 { + + self.showTime = 0.4 + } + }) + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW,Int64(0.8 * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), {[unowned self] () -> Void in + + + if self.showTime == 0.4 { + + self.showTime = 0.2 + } + }) + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW,Int64(1 * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), {[unowned self] () -> Void in + + if self.showTime == 0.2 { + + self.dismissIndexTitle() + } + + + }) + + return indexTitleIndexArray[index] + } + + + func showIndexTitle(indexTitle: String){ + + self.dismissBtn.enabled = false + self.view.userInteractionEnabled = false + indexTitleLabel.text = indexTitle + self.view.window?.addSubview(indexTitleLabel) + + } + + func dismissIndexTitle(){ + self.dismissBtn.enabled = true + self.view.userInteractionEnabled = true + indexTitleLabel.removeFromSuperview() + } + + + /** 选中城市处理 */ + func citySelected(cityModel: CityModel){ + +// self.selectedCityArray.insert(cityModel.name, atIndex: 0) + self.selectedCityArray.append(cityModel.name) + + NSUserDefaults.standardUserDefaults().setObject(self.selectedCityArray, forKey: SelectedCityKey) + selectedCityModel?(cityModel: cityModel) + self.dismiss() + } + +} + + + +extension CFCityPickerVC{ + + /** 处理索引 */ + func indexHandle() -> [String] { + + var indexArr: [String] = [] + + for (index,cityModel) in enumerate(sortedCityModles) { + let indexString = cityModel.getFirstUpperLetter + + if contains(indexArr, indexString) {continue} + + indexArr.append(indexString) + + indexTitleIndexArray.append(index) + } + + return indexArr + } + + + +} + diff --git a/CFCityPickerVC/CFCityPickerVC/Model/CityModel.swift b/CFCityPickerVC/CFCityPickerVC/Model/CityModel.swift new file mode 100644 index 0000000..ac592fc --- /dev/null +++ b/CFCityPickerVC/CFCityPickerVC/Model/CityModel.swift @@ -0,0 +1,73 @@ +// +// CityModel.swift +// CFCityPickerVC +// +// Created by 冯成林 on 15/7/30. +// Copyright (c) 2015年 冯成林. All rights reserved. +// + +import Foundation + + +extension CFCityPickerVC { + + class CityModel { + + let id: Int + let pid: Int + let name: String + let spell: String + var children: [CityModel]? + + init(id: Int, pid: Int, name: String, spell: String){ + + self.id = id + self.pid = pid + self.name = name + self.spell = spell + } + + + + /** 首字母获取 */ + var getFirstUpperLetter: String {return (self.spell as NSString).substringToIndex(1).uppercaseString} + + + /** 寻找城市模型:单个 */ + class func findCityModelWithCityName(cityNames: [String]?, cityModels: [CityModel]) -> [CityModel]?{ + + if cityNames == nil {return nil} + + var destinationModels: [CityModel]? = [] + + for cityModel in cityModels{ + + if cityModel.children == nil {continue} + + + for name in cityNames!{ + + println(name) + for cityModel2 in cityModel.children! { + + if cityModel2.name != name {continue} + + destinationModels?.append(cityModel2) + } + + } + + } + + + return destinationModels + } + + + + } + + + + +} \ No newline at end of file diff --git a/CFCityPickerVC/CFCityPickerVC/Resource/img.bundle/cancel@2x.png b/CFCityPickerVC/CFCityPickerVC/Resource/img.bundle/cancel@2x.png new file mode 100644 index 0000000..44194b5 Binary files /dev/null and b/CFCityPickerVC/CFCityPickerVC/Resource/img.bundle/cancel@2x.png differ diff --git a/CFCityPickerVC/CFCityPickerVC/Resource/img.bundle/cancel@3x.png b/CFCityPickerVC/CFCityPickerVC/Resource/img.bundle/cancel@3x.png new file mode 100644 index 0000000..54d9f01 Binary files /dev/null and b/CFCityPickerVC/CFCityPickerVC/Resource/img.bundle/cancel@3x.png differ diff --git a/CFCityPickerVC/CFCityPickerVC/View/CFCityCell.swift b/CFCityPickerVC/CFCityPickerVC/View/CFCityCell.swift new file mode 100644 index 0000000..43e8a67 --- /dev/null +++ b/CFCityPickerVC/CFCityPickerVC/View/CFCityCell.swift @@ -0,0 +1,41 @@ +// +// CFCityCell.swift +// CFCityPickerVC +// +// Created by 冯成林 on 15/7/30. +// Copyright (c) 2015年 冯成林. All rights reserved. +// + +import UIKit + +class CFCityCell: UITableViewCell { + + var cityModel: CFCityPickerVC.CityModel! {didSet{dataFill()}} + +} + + + +extension CFCityCell{ + + static var rid: String {return "CFCityCell"} + + class func cityCellInTableView(tableView: UITableView) -> CFCityCell { + + //取出cell + var cityCell = tableView.dequeueReusableCellWithIdentifier(rid) as?CFCityCell + + if cityCell == nil {cityCell = CFCityCell(style: UITableViewCellStyle.Default, reuseIdentifier: rid)} + + return cityCell! + } + + + /** 数据填充 */ + func dataFill(){ + + self.textLabel?.text = "\(cityModel.name)" + + } + +} diff --git a/CFCityPickerVC/CFCityPickerVC/View/CFCityCell.xib b/CFCityPickerVC/CFCityPickerVC/View/CFCityCell.xib new file mode 100644 index 0000000..3389ec9 --- /dev/null +++ b/CFCityPickerVC/CFCityPickerVC/View/CFCityCell.xib @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/CFCityPickerVC/CFCityPickerVC/View/HeaderItemView.swift b/CFCityPickerVC/CFCityPickerVC/View/HeaderItemView.swift new file mode 100644 index 0000000..8c15259 --- /dev/null +++ b/CFCityPickerVC/CFCityPickerVC/View/HeaderItemView.swift @@ -0,0 +1,145 @@ +// +// HeaderItemView.swift +// CFCityPickerVC +// +// Created by 冯成林 on 15/7/30. +// Copyright (c) 2015年 冯成林. All rights reserved. +// + +import UIKit + +class HeaderItemView: UIView { + + @IBOutlet weak var itemLabel: UILabel! + + @IBOutlet weak var lineView: UIView! + @IBOutlet weak var lineViewHC: NSLayoutConstraint! + + @IBOutlet weak var msgLabel: UILabel! + + @IBOutlet weak var contentView: CFCPContentView! + + var cityModles: [CFCityPickerVC.CityModel]!{didSet{dataCome()}} +} + + +extension HeaderItemView{ + + override func awakeFromNib() { + + super.awakeFromNib() + + lineViewHC.constant = 0.5 + } + + func dataCome(){ + self.msgLabel.hidden = cityModles.count != 0 + self.contentView.cityModles = cityModles + } + + + class func getHeaderItemView(title: String) -> HeaderItemView{ + + let itemView = NSBundle.mainBundle().loadNibNamed("HeaderItemView", owner: nil, options: nil).first as! HeaderItemView + itemView.itemLabel.text = title + + return itemView + } +} + + +extension CFCPContentView{ + + class ItemBtn: UIButton { + + var cityModel: CFCityPickerVC.CityModel! + + required init(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + + /** 视图准备 */ + self.viewPrepare() + } + + override init(frame: CGRect) { + super.init(frame: frame) + + /** 视图准备 */ + self.viewPrepare() + } + + /** 视图准备 */ + func viewPrepare(){ + + self.setTitleColor(CFCityPickerVC.rgba(31, g: 31, b: 31, a: 1), forState: UIControlState.Normal) + self.setTitleColor(CFCityPickerVC.rgba(141, g: 141, b: 141, a: 1), forState: UIControlState.Highlighted) + self.titleLabel?.font = UIFont.systemFontOfSize(15) + self.layer.cornerRadius = 4 + self.layer.masksToBounds = true + self.backgroundColor = CFCityPickerVC.rgba(241, g: 241, b: 241, a: 1) + } + } + +} + + +class CFCPContentView: UIView{ + + var cityModles: [CFCityPickerVC.CityModel]!{didSet{btnsPrepare()}} + + let maxRowCount = 4 + var btns: [ItemBtn] = [] + + + + /** 添加按钮 */ + func btnsPrepare(){ + + if cityModles == nil {return} + + for cityModel in cityModles{ + + let itemBtn = ItemBtn() + itemBtn.setTitle(cityModel.name, forState: UIControlState.Normal) + itemBtn.addTarget(self, action: "btnClick:", forControlEvents: UIControlEvents.TouchUpInside) + btns.append(itemBtn) + itemBtn.cityModel = cityModel + self.addSubview(itemBtn) + } + } + + + /** 按钮点击事件 */ + func btnClick(btn: ItemBtn){ + + NSNotificationCenter.defaultCenter().postNotificationName(CityChoosedNoti, object: nil, userInfo: ["citiModel":btn.cityModel]) + } + + + override func layoutSubviews() { + + super.layoutSubviews() + + if btns.count == 0 {return} + let marginForRow: CGFloat = 16.0 + let marginForCol: CGFloat = 13 + let width: CGFloat = (self.bounds.size.width - (CGFloat(maxRowCount - 1)) * marginForRow) / CGFloat(maxRowCount) + + let height: CGFloat = 30 + for (index,btn) in enumerate(btns) { + + let row = index % maxRowCount + + let col = index / maxRowCount + + let x = (width + marginForRow) * CGFloat(row) + let y = (height + marginForCol) * CGFloat(col) + + btn.frame = CGRectMake(x, y, width, height) + } + } + +} + + + diff --git a/CFCityPickerVC/CFCityPickerVC/View/HeaderItemView.xib b/CFCityPickerVC/CFCityPickerVC/View/HeaderItemView.xib new file mode 100644 index 0000000..2e3056a --- /dev/null +++ b/CFCityPickerVC/CFCityPickerVC/View/HeaderItemView.xib @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CFCityPickerVC/City.plist b/CFCityPickerVC/City.plist new file mode 100644 index 0000000..8ceaf1c --- /dev/null +++ b/CFCityPickerVC/City.plist @@ -0,0 +1,4 @@ + + + + id1001name安徽pid0spellAnhuishengchildrenid1002name合肥pid1001spellHefeiid1008name芜湖pid1001spellWuhuid1016name蚌埠pid1001spellBangbuid1024name淮南pid1001spellHuainanid1031name马鞍山pid1001spellMaanshanid1036name淮北pid1001spellHuaibeiid1041name铜陵pid1001spellTonglingid1046name安庆pid1001spellAnqingid1058name黄山pid1001spellHuangshanid1066name滁州pid1001spellChuzhouid1075name阜阳pid1001spellFuyangid1084name宿州pid1001spellXiuzhouid1090name巢湖pid1001spellChaohuid1096name六安pid1001spellLiuanid1104name亳州pid1001spellBozhouid1109name池州pid1001spellShizhouid1114name宣城pid1001spellXuanchengid29name重庆pid0spellChongqingshichildrenid30name重庆pid29spellzhongqingshiid1122name福建pid0spellFujianshengchildrenid1123name福州pid1122spellFuzhouid1128name厦门pid1122spellShamenid1135name莆田pid1122spellPutianid1141name三明pid1122spellSanmingid1154name泉州pid1122spellQuanzhouid1167name漳州pid1122spellZhangzhouid1179name南平pid1122spellNanpingid1190name龙岩pid1122spellLongyanid1198name宁德pid1122spellNingdeid2800name甘肃pid0spellGansushengchildrenid2801name兰州pid2800spellLanzhouid2808name嘉峪关pid2800spellJiayuguanid2810name金昌pid2800spellJinchangid2813name白银pid2800spellBaiyinid2819name天水pid2800spellTianshuiid2827name武威pid2800spellWuweiid2832name张掖pid2800spellZhangyeid2839name平凉pid2800spellPingliangid2847name酒泉pid2800spellJiuquanid2855name庆阳pid2800spellQingyangid2864name定西pid2800spellDingxiid2872name陇南pid2800spellLongnanid2882name临夏自治州pid2800spellLinxiazizhizhouid2891name甘南自治州pid2800spellGannanzizhizhouid1359name广东pid0spellGuangdongshengchildrenid1360name广州pid1359spellguangzhouid1373name韶关pid1359spellShaoguanid1384name深圳pid1359spellShenchouid1391name珠海pid1359spellZhuhaiid1395name汕头pid1359spellShantouid1403name佛山pid1359spellFoshanid1409name江门pid1359spellJiangmenid1417name湛江pid1359spellZhanjiangid1427name茂名pid1359spellMaomingid1434name肇庆pid1359spellZhaoqingid1443name惠州pid1359spellHuizhouid1449name梅州pid1359spellMeizhouid1458name汕尾pid1359spellShanweiid1463name河源pid1359spellHeyuanid1470name阳江pid1359spellYangjiangid1475name清远pid1359spellQingyuanid1484name潮州pid1359spellChaozhouid1488name揭阳pid1359spellJieyangid1494name云浮pid1359spellYunfuid3097name东莞pid1359spellDongguanid1500name广西pid0spellGuangxishengchildrenid1501name南宁pid1500spellNanningid1507name柳州pid1500spellLiuzhouid1518name桂林pid1500spellGuilinid1536name梧州pid1500spellWuzhouid1544name北海pid1500spellBeihaiid1549name防城港pid1500spellFangchenggangid1554name钦州pid1500spellQinzhouid1559name贵港pid1500spellGuigangid1565name玉林pid1500spellYulinid1572name百色pid1500spellBaiseid1585name贺州pid1500spellHezhouid1590name河池pid1500spellHeshiid1602name来宾pid1500spellLaibinid1609name崇左pid1500spellChongzuoid2371name贵州pid0spellGuizhoushengchildrenid2372name贵阳pid2371spellGuiyangid2380name六盘水pid2371spellLiupanshuiid2385name遵义pid2371spellZunyiid2400name安顺pid2371spellAnshunid2407name铜仁地区pid2371spellTongrendiquid2418name黔西南自治州pid2371spellQianxinanzizhizhouid2427name毕节地区pid2371spellBijiediquid2436name黔东南自治州pid2371spellQianDongNanZiZhiZhouid2453name黔南自治州pid2371spellQiannanzizhizhouid1617name海南pid0spellHainanshengchildrenid1618name海口pid1617spellHaikouid1623name三亚pid1617spellSanyaid1625name海南直辖县pid1617spellHainanzhixiaxianid67name河北pid0spellHebeishengchildrenid68name石家庄pid67spellShijiazhuangshiid76name唐山pid67spellTangshanshiid91name秦皇岛pid67spellQinhuangdaoshiid99name邯郸pid67spellHandanshiid119name邢台pid67spellXingtaishiid139name保定pid67spellBaodingshiid165name张家口pid67spellZhangjiakoushiid183name承德pid67spellChengdeshiid195name沧州pid67spellCangzhoushiid212name廊坊pid67spellLangfangshiid223name衡水pid67spellHengshuishiid654name黑龙江pid0spellHeilongjiangshengchildrenid655name哈尔滨pid654spellHaerbinid664name齐齐哈尔pid654spellQiqihaerid681name鸡西pid654spellJixiid691name鹤岗pid654spellHegangid700name双鸭山pid654spellShuangyashanid709name大庆pid654spellDaqingid719name伊春pid654spellYichunid737name佳木斯pid654spellJiamusiid749name七台河pid654spellQitaiheid754name牡丹江pid654spellMudanjiangid765name黑河pid654spellHeiheid772name绥化pid654spellSuihuaid783name大兴安岭地区pid654spellDaxinganlingdiquid1755name河南pid0spellHenanshengchildrenid1756name郑州pid1755spellZhengzhouid1764name开封pid1755spellKaifengid1775name洛阳pid1755spellLuoyangid1791name平顶山pid1755spellPingdingshanid1802name安阳pid1755spellAnyangid1812name鹤壁pid1755spellHebiid1818name新乡pid1755spellXinxiangid1831name焦作pid1755spellJiaozuoid1843name濮阳pid1755spellPuyangid1850name许昌pid1755spellXuchangid1857name漯河pid1755spellLeiheid1863name三门峡pid1755spellSanmenxiaid1870name南阳pid1755spellNanyangid1884name商丘pid1755spellShangqiuid1894name信阳pid1755spellXinyangid1905name周口pid1755spellZhoukouid1916name驻马店pid1755spellZhumadianid1927name湖北pid0spellHubeishengchildrenid1928name武汉pid1927spellWuhanid1942name黄石pid1927spellHuangshiid1949name十堰pid1927spellShiyanid1958name宜昌pid1927spellYichangid1972name襄樊pid1927spellXiangfanid1982name鄂州pid1927spellEzhouid1986name荆门pid1927spellJingmenid1992name孝感pid1927spellXiaoganid2000name荆州pid1927spellJingzhouid2009name黄冈pid1927spellHuanggangid2020name咸宁pid1927spellXianningid2027name随州pid1927spellSuizhouid2030name恩施自治州pid1927spellEnshizizhizhouid2039name湖北辖单位pid1927spellHubeishengxiadanweiid2044name湖南pid0spellHunanshengchildrenid2045name长沙pid2044spellChangshaid2055name株洲pid2044spellZhuzhouid2065name湘潭pid2044spellXiangtanid2071name衡阳pid2044spellHengyangid2084name邵阳pid2044spellShaoyangid2097name岳阳pid2044spellYueyangid2107name常德pid2044spellChangdeid2117name张家界pid2044spellZhangjiajieid2122name益阳pid2044spellYiyangid2129name郴州pid2044spellChenzhouid2141name永州pid2044spellYongzhouid2153name怀化pid2044spellHuaihuaid2166name娄底pid2044spellLoudiid2172name湘西自治州pid2044spellXiangxizizhizhouid788name江苏pid0spellJiangsushengchildrenid789name南京pid788spellNanjingid799name无锡pid788spellWuxiid808name徐州pid788spellXuzhouid820name常州pid788spellChangzhouid828name苏州pid788spellSuzhouid840name南通pid788spellNantongid849name连云港pid788spellLianyungangid857name淮安pid788spellHuaianid866name盐城pid788spellYanchengid876name扬州pid788spellYangzhouid884name镇江pid788spellZhenjiangid891name泰州pid788spellTaizhouid898name宿迁pid788spellXiuqianid1646name江西pid0spellJiangxishengchildrenid1647name南昌pid1646spellNanchangid1655name景德镇pid1646spellJingdezhenid1660name萍乡pid1646spellPingxiangid1666name九江pid1646spellJiujiangid1679name新余pid1646spellXinyuid1682name鹰潭pid1646spellYingtanid1686name赣州pid1646spellGanzhouid1705name吉安pid1646spellJianid1719name宜春pid1646spellYichunid1730name抚州pid1646spellFuzhouid1742name上饶pid1646spellShangraoid584name吉林pid0spellJilinshengchildrenid585name长春pid584spellChangchunid596name吉林pid584spellJilinid606name四平pid584spellSipingid613name辽源pid584spellLiaoyuanid618name通化pid584spellTonghuaid626name白山pid584spellBaishanid633name松原pid584spellSongyuanid639name白城pid584spellBaichengid645name延边自治州pid584spellYanbianzizhizhouid473name辽宁pid0spellLiaoningshengchildrenid474name沈阳pid473spellShenyangid484name大连pid473spellDalianid495name鞍山pid473spellAnshanid503name抚顺pid473spellFushunid511name本溪pid473spellBenxiid518name丹东pid473spellDandongid525name锦州pid473spellJinzhouid533name营口pid473spellYingkouid540name阜新pid473spellFuxinid548name辽阳pid473spellLiaoyangid556name盘锦pid473spellPanjinid561name铁岭pid473spellTielingid569name朝阳pid473spellChaoyangid577name葫芦岛pid473spellHuludaoid363name内蒙古区pid0spellNeimengguquchildrenid364name呼和浩特pid363spellHuhehaoteid370name包头pid363spellBaotouid380name乌海pid363spellWuhaiid384name赤峰pid363spellChifengid397name通辽pid363spellTongliaoid406name鄂尔多斯pid363spellEerduosiid415name呼伦贝尔pid363spellHulunbeierid429name巴彦淖尔pid363spellBayannaoerid437name乌兰察布pid363spellWulanchabuid449name兴安盟pid363spellXinganmengid456name锡林郭勒盟pid363spellXilinguolemengid469name阿拉善盟pid363spellAlashanmengid2952name宁夏区pid0spellNingxiaquchildrenid2953name银川pid2952spellYinchuanid2960name石嘴山pid2952spellShizuishanid2964name吴忠pid2952spellWuzhongid2969name固原pid2952spellGuyuanid2975name中卫pid2952spellZhongweiid2900name青海pid0spellQinghaishengchildrenid2901name西宁pid2900spellXiningid2909name海东地区pid2900spellHaidongdiquid2916name海北自治州pid2900spellHaibeizizhizhouid2921name黄南自治州pid2900spellHuangnanzizhizhouid2926name海南自治州pid2900spellHainanzizhizhouid2932name果洛自治州pid2900spellGuoluozizhizhouid2939name玉树自治州pid2900spellYushuzizhizhouid2946name海西自治州pid2900spellHaixizizhizhouid1208name山东pid0spellShandongshengchildrenid1209name济南pid1208spellJinanid1217name青岛pid1208spellQingdaoid1225name淄博pid1208spellZiboid1234name枣庄pid1208spellZaozhuangid1241name东营pid1208spellDongyingid1247name烟台pid1208spellYantaiid1260name潍坊pid1208spellWeifangid1273name济宁pid1208spellJiningid1286name泰安pid1208spellTaianid1293name威海pid1208spellWeihaiid1298name日照pid1208spellRizhaoid1303name莱芜pid1208spellLaiwuid1306name临沂pid1208spellLinyiid1319name德州pid1208spellDezhouid1331name聊城pid1208spellLiaochengid1340name滨州pid1208spellBinzhouid1348name荷泽pid1208spellHezeid47name上海pid0spellShanghaishichildrenid48name上海pid47spellshanghaishiid235name山西pid0spellShanxishengchildrenid236name太原pid235spellTaiyuanid244name大同pid235spellDatongid256name阳泉pid235spellYangquanid262name长治pid235spellChangzhiid276name晋城pid235spellJinchengid283name朔州pid235spellShuozhouid290name晋中pid235spellJinzhongid302name运城pid235spellYunchengid316name忻州pid235spellXinzhouid331name临汾pid235spellLinfenid349name吕梁pid235spellLuliangid2685name陕西pid0spellShanxishengchildrenid2686name西安pid2685spellXianid2697name铜川pid2685spellTongchuanid2702name宝鸡pid2685spellBaojiid2715name咸阳pid2685spellXianyangid2730name渭南pid2685spellWeinanid2742name延安pid2685spellYananid2756name汉中pid2685spellHanzhongid2768name榆林pid2685spellYulinid2781name安康pid2685spellAnkangid2792name商洛pid2685spellShangluoid2181name四川pid0spellSichuanshengchildrenid2182name成都pid2181spellchengdouid2189name自贡pid2181spellZigongid2196name攀枝花pid2181spellPanzhihuaid2202name泸州pid2181spellLuzhouid2210name德阳pid2181spellDeyangid2217name绵阳pid2181spellMianyangid2227name广元pid2181spellGuangyuanid2235name遂宁pid2181spellSuiningid2241name内江pid2181spellNeijiangid2247name乐山pid2181spellLeshanid2259name南充pid2181spellNanchongid2269name眉山pid2181spellMeishanid2276name宜宾pid2181spellYibinid2287name广安pid2181spellGuanganid2293name达州pid2181spellDazhouid2301name雅安pid2181spellYaanid2310name巴中pid2181spellBazhongid2315name资阳pid2181spellZiyangid2320name阿坝自治州pid2181spellAbazizhizhouid2334name甘孜自治州pid2181spellGanzizizhizhouid2353name凉山自治州pid2181spellLiangshanzizhizhouid16name天津pid0spellTianjinshichildrenid17name天津pid16spellTianjinid2604name西藏区pid0spellXicangquchildrenid2605name拉萨pid2604spellLasaid2614name昌都地区pid2604spellChangdoudiquid2626name山南地区pid2604spellShannandiquid2639name日喀则地区pid2604spellRikazediquid2658name那曲地区pid2604spellNaqudiquid2669name阿里地区pid2604spellAlidiquid2677name林芝地区pid2604spellLinzhidiquid2979name新疆区pid0spellXinjiangquchildrenid2980name乌鲁木齐pid2979spellWulumuqiid2989name克拉玛依pid2979spellKelamayiid2994name吐鲁番地区pid2979spellTulufandiquid2998name哈密地区pid2979spellHamidiquid3002name昌吉自治州pid2979spellChangjizizhizhouid3011name博尔塔拉州pid2979spellBoertalazhouid3015name巴音郭楞州pid2979spellBayinguolengzhouid3025name阿克苏地区pid2979spellAkesudiquid3035name克孜勒苏州pid2979spellKezilesuzhouid3040name喀什地区pid2979spellKashidiquid3053name和田地区pid2979spellHetiandiquid3062name伊犁自治州pid2979spellYilizizhizhouid3073name塔城地区pid2979spellTachengdiquid3081name阿勒泰地区pid2979spellAletaidiquid3089name新疆辖单位pid2979spellXinJiangShengXiaDanWid2466name云南pid0spellYunnanshengchildrenid2467name昆明pid2466spellKunmingid2474name曲靖pid2466spellQujingid2484name玉溪pid2466spellYuxiid2494name保山pid2466spellBaoshanid2500name昭通pid2466spellZhaotongid2512name丽江pid2466spellLijiangid2518name思茅pid2466spellSimaoid2529name临沧pid2466spellLincangid2538name楚雄自治州pid2466spellChuxiongzizhizhouid2549name红河自治州pid2466spellHonghezizhizhouid2563name文山自治州pid2466spellWenshanzizhizhouid2572name西双版纳州pid2466spellXishuangbannazhouid2576name大理自治州pid2466spellDalizizhizhouid2589name德宏自治州pid2466spellDehongzizhizhouid2595name怒江傈自治州pid2466spellNujianglizizhizhouid2600name迪庆自治州pid2466spellDiqingzizhizhouid904name浙江pid0spellZhejiangshengchildrenid905name杭州pid904spellHangzhouid914name宁波pid904spellNingboid926name温州pid904spellWenzhouid938name嘉兴pid904spellJiaxingid946name湖州pid904spellHuzhouid952name绍兴pid904spellShaoxingid959name金华pid904spellJinhuaid969name衢州pid904spellQuzhouid976name舟山pid904spellZhoushanid981name台州pid904spellTaizhouid991name丽水pid904spellLishuiid3100name北京pid0spellbeijingshichildrenid3101name北京pid3100spellbeijing diff --git a/CFCityPickerVC/Images.xcassets/AppIcon.appiconset/Contents.json b/CFCityPickerVC/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..118c98f --- /dev/null +++ b/CFCityPickerVC/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CFCityPickerVC/Images.xcassets/LaunchImage.launchimage/Contents.json b/CFCityPickerVC/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..e37b649 --- /dev/null +++ b/CFCityPickerVC/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "minimum-system-version" : "7.0", + "subtype" : "retina4", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CFCityPickerVC/Info.plist b/CFCityPickerVC/Info.plist new file mode 100644 index 0000000..98e3768 --- /dev/null +++ b/CFCityPickerVC/Info.plist @@ -0,0 +1,40 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + HM.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/CFCityPickerVC/ViewController.swift b/CFCityPickerVC/ViewController.swift new file mode 100644 index 0000000..0470f60 --- /dev/null +++ b/CFCityPickerVC/ViewController.swift @@ -0,0 +1,132 @@ +// +// ViewController.swift +// CFCityPickerVC +// +// Created by 冯成林 on 15/7/29. +// Copyright (c) 2015年 冯成林. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + } + + + @IBAction func showAction(sender: AnyObject) { + + //目前有如下问题 + + //1.顺序不对 + //2.历史重复添加、数量超过8个 + //3.还没做定位 + //4.headerView的高度是写死的 + + + + + + let cityVC = CFCityPickerVC.getInstance() + +// //设置当前城市 +// cityVC.currentCity = "成都" + + + //设置热门城市 + cityVC.hotCities = ["北京","上海","广州","成都","杭州","重庆"] + + + let navVC = UINavigationController(rootViewController: cityVC) + navVC.navigationBar.barStyle = UIBarStyle.BlackTranslucent + + self.presentViewController(navVC, animated: true, completion: nil) + + //解析字典数据 + let cityModels = cityModelsPrepare() + cityVC.cityModels = cityModels + + //选中了城市 + cityVC.selectedCityModel = { (cityModel: CFCityPickerVC.CityModel) in + + + println("您选中了城市: \(cityModel.name)") + + } + + } + +} + + + + + + + + + + + + + + + + + + + + + + +extension ViewController{ + + /** 解析字典数据,由于swift中字典转模型工具不完善,这里先手动处理 */ + func cityModelsPrepare() -> [CFCityPickerVC.CityModel]{ + + //加载plist,你也可以加载网络数据 + let plistUrl = NSBundle.mainBundle().URLForResource("City", withExtension: "plist")! + let cityArray = NSArray(contentsOfURL: plistUrl) as! [NSDictionary] + + var cityModels: [CFCityPickerVC.CityModel] = [] + + for dict in cityArray{ + let cityModel = parse(dict) + cityModels.append(cityModel) + } + + return cityModels + } + + func parse(dict: NSDictionary) -> CFCityPickerVC.CityModel{ + + let id = dict["id"] as! Int + let pid = dict["pid"] as! Int + let name = dict["name"] as! String + let spell = dict["spell"] as! String + + let cityModel = CFCityPickerVC.CityModel(id: id, pid: pid, name: name, spell: spell) + + let children = dict["children"] + + if children != nil { //有子级 + + var childrenArr: [CFCityPickerVC.CityModel] = [] + for childDict in children as! NSArray { + + let childrencityModel = parse(childDict as! NSDictionary) + + childrenArr.append(childrencityModel) + } + + cityModel.children = childrenArr + } + + + return cityModel + } + +} + diff --git a/CFCityPickerVCTests/CFCityPickerVCTests.swift b/CFCityPickerVCTests/CFCityPickerVCTests.swift new file mode 100644 index 0000000..a4af86e --- /dev/null +++ b/CFCityPickerVCTests/CFCityPickerVCTests.swift @@ -0,0 +1,36 @@ +// +// CFCityPickerVCTests.swift +// CFCityPickerVCTests +// +// Created by 冯成林 on 15/7/29. +// Copyright (c) 2015年 冯成林. All rights reserved. +// + +import UIKit +import XCTest + +class CFCityPickerVCTests: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // This is an example of a functional test case. + XCTAssert(true, "Pass") + } + + func testPerformanceExample() { + // This is an example of a performance test case. + self.measureBlock() { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/CFCityPickerVCTests/Info.plist b/CFCityPickerVCTests/Info.plist new file mode 100644 index 0000000..7e47382 --- /dev/null +++ b/CFCityPickerVCTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + HM.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + +