├── README.md ├── SelectCityDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ ├── ZJ.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── SelectCityDemo.xcscheme │ │ └── xcschememanagement.plist │ └── liyang.xcuserdatad │ └── xcschemes │ ├── SelectCityDemo.xcscheme │ └── xcschememanagement.plist ├── SelectCityDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m ├── main.m └── selectCity │ ├── Controller │ ├── CityViewController.h │ ├── CityViewController.m │ ├── ResultCityController.h │ └── ResultCityController.m │ ├── Model │ ├── CityModel.h │ └── CityModel.m │ ├── View │ ├── CityTableViewCell.h │ ├── CityTableViewCell.m │ ├── CustomSearchView.h │ ├── CustomSearchView.m │ ├── CustomTopView.h │ └── CustomTopView.m │ ├── cancelBtn@2x.png │ └── citydict.plist ├── SelectCityDemoTests ├── Info.plist └── SelectCityDemoTests.m ├── SelectCityDemoUITests ├── Info.plist └── SelectCityDemoUITests.m └── selectCity.gif /README.md: -------------------------------------------------------------------------------- 1 | # SelectCityDemo 2 | 3 | 仿百度糯米实现的城市选择界面,只需几行代码就可集成! 4 | 热门城市选择,城市汉字搜索及拼音搜索 5 | ![image](https://github.com/coderZhou10496/SelectCityDemo/blob/master/selectCity.gif) 6 | 7 | -------------------------------------------------------------------------------- /SelectCityDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B66154251BE9952400FC9689 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B66154241BE9952400FC9689 /* main.m */; }; 11 | B66154281BE9952400FC9689 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B66154271BE9952400FC9689 /* AppDelegate.m */; }; 12 | B661542B1BE9952400FC9689 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B661542A1BE9952400FC9689 /* ViewController.m */; }; 13 | B661542E1BE9952400FC9689 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B661542C1BE9952400FC9689 /* Main.storyboard */; }; 14 | B66154301BE9952400FC9689 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B661542F1BE9952400FC9689 /* Assets.xcassets */; }; 15 | B66154331BE9952400FC9689 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B66154311BE9952400FC9689 /* LaunchScreen.storyboard */; }; 16 | B661543E1BE9952400FC9689 /* SelectCityDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B661543D1BE9952400FC9689 /* SelectCityDemoTests.m */; }; 17 | B66154491BE9952400FC9689 /* SelectCityDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = B66154481BE9952400FC9689 /* SelectCityDemoUITests.m */; }; 18 | B66154661BE9953100FC9689 /* cancelBtn@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B66154571BE9953100FC9689 /* cancelBtn@2x.png */; }; 19 | B66154671BE9953100FC9689 /* citydict.plist in Resources */ = {isa = PBXBuildFile; fileRef = B66154581BE9953100FC9689 /* citydict.plist */; }; 20 | B66154681BE9953100FC9689 /* CityViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B661545B1BE9953100FC9689 /* CityViewController.m */; }; 21 | B66154691BE9953100FC9689 /* ResultCityController.m in Sources */ = {isa = PBXBuildFile; fileRef = B661545D1BE9953100FC9689 /* ResultCityController.m */; }; 22 | B661546A1BE9953100FC9689 /* CityModel.m in Sources */ = {isa = PBXBuildFile; fileRef = B66154601BE9953100FC9689 /* CityModel.m */; }; 23 | B661546B1BE9953100FC9689 /* CityTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B66154631BE9953100FC9689 /* CityTableViewCell.m */; }; 24 | B661546C1BE9953100FC9689 /* CustomTopView.m in Sources */ = {isa = PBXBuildFile; fileRef = B66154651BE9953100FC9689 /* CustomTopView.m */; }; 25 | B66154721BE996A600FC9689 /* CustomSearchView.m in Sources */ = {isa = PBXBuildFile; fileRef = B66154711BE996A600FC9689 /* CustomSearchView.m */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | B661543A1BE9952400FC9689 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = B66154181BE9952400FC9689 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = B661541F1BE9952400FC9689; 34 | remoteInfo = SelectCityDemo; 35 | }; 36 | B66154451BE9952400FC9689 /* PBXContainerItemProxy */ = { 37 | isa = PBXContainerItemProxy; 38 | containerPortal = B66154181BE9952400FC9689 /* Project object */; 39 | proxyType = 1; 40 | remoteGlobalIDString = B661541F1BE9952400FC9689; 41 | remoteInfo = SelectCityDemo; 42 | }; 43 | /* End PBXContainerItemProxy section */ 44 | 45 | /* Begin PBXFileReference section */ 46 | B66154201BE9952400FC9689 /* SelectCityDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SelectCityDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | B66154241BE9952400FC9689 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 48 | B66154261BE9952400FC9689 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 49 | B66154271BE9952400FC9689 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 50 | B66154291BE9952400FC9689 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 51 | B661542A1BE9952400FC9689 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 52 | B661542D1BE9952400FC9689 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 53 | B661542F1BE9952400FC9689 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 54 | B66154321BE9952400FC9689 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 55 | B66154341BE9952400FC9689 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | B66154391BE9952400FC9689 /* SelectCityDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SelectCityDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | B661543D1BE9952400FC9689 /* SelectCityDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SelectCityDemoTests.m; sourceTree = ""; }; 58 | B661543F1BE9952400FC9689 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | B66154441BE9952400FC9689 /* SelectCityDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SelectCityDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 60 | B66154481BE9952400FC9689 /* SelectCityDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SelectCityDemoUITests.m; sourceTree = ""; }; 61 | B661544A1BE9952400FC9689 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 62 | B66154571BE9953100FC9689 /* cancelBtn@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "cancelBtn@2x.png"; sourceTree = ""; }; 63 | B66154581BE9953100FC9689 /* citydict.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = citydict.plist; sourceTree = ""; }; 64 | B661545A1BE9953100FC9689 /* CityViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CityViewController.h; sourceTree = ""; }; 65 | B661545B1BE9953100FC9689 /* CityViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CityViewController.m; sourceTree = ""; }; 66 | B661545C1BE9953100FC9689 /* ResultCityController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResultCityController.h; sourceTree = ""; }; 67 | B661545D1BE9953100FC9689 /* ResultCityController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ResultCityController.m; sourceTree = ""; }; 68 | B661545F1BE9953100FC9689 /* CityModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CityModel.h; sourceTree = ""; }; 69 | B66154601BE9953100FC9689 /* CityModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CityModel.m; sourceTree = ""; }; 70 | B66154621BE9953100FC9689 /* CityTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CityTableViewCell.h; sourceTree = ""; }; 71 | B66154631BE9953100FC9689 /* CityTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CityTableViewCell.m; sourceTree = ""; }; 72 | B66154641BE9953100FC9689 /* CustomTopView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomTopView.h; sourceTree = ""; }; 73 | B66154651BE9953100FC9689 /* CustomTopView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomTopView.m; sourceTree = ""; }; 74 | B66154701BE996A600FC9689 /* CustomSearchView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomSearchView.h; sourceTree = ""; }; 75 | B66154711BE996A600FC9689 /* CustomSearchView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomSearchView.m; sourceTree = ""; }; 76 | /* End PBXFileReference section */ 77 | 78 | /* Begin PBXFrameworksBuildPhase section */ 79 | B661541D1BE9952400FC9689 /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | ); 84 | runOnlyForDeploymentPostprocessing = 0; 85 | }; 86 | B66154361BE9952400FC9689 /* Frameworks */ = { 87 | isa = PBXFrameworksBuildPhase; 88 | buildActionMask = 2147483647; 89 | files = ( 90 | ); 91 | runOnlyForDeploymentPostprocessing = 0; 92 | }; 93 | B66154411BE9952400FC9689 /* Frameworks */ = { 94 | isa = PBXFrameworksBuildPhase; 95 | buildActionMask = 2147483647; 96 | files = ( 97 | ); 98 | runOnlyForDeploymentPostprocessing = 0; 99 | }; 100 | /* End PBXFrameworksBuildPhase section */ 101 | 102 | /* Begin PBXGroup section */ 103 | B66154171BE9952400FC9689 = { 104 | isa = PBXGroup; 105 | children = ( 106 | B66154221BE9952400FC9689 /* SelectCityDemo */, 107 | B661543C1BE9952400FC9689 /* SelectCityDemoTests */, 108 | B66154471BE9952400FC9689 /* SelectCityDemoUITests */, 109 | B66154211BE9952400FC9689 /* Products */, 110 | ); 111 | sourceTree = ""; 112 | }; 113 | B66154211BE9952400FC9689 /* Products */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | B66154201BE9952400FC9689 /* SelectCityDemo.app */, 117 | B66154391BE9952400FC9689 /* SelectCityDemoTests.xctest */, 118 | B66154441BE9952400FC9689 /* SelectCityDemoUITests.xctest */, 119 | ); 120 | name = Products; 121 | sourceTree = ""; 122 | }; 123 | B66154221BE9952400FC9689 /* SelectCityDemo */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | B66154261BE9952400FC9689 /* AppDelegate.h */, 127 | B66154271BE9952400FC9689 /* AppDelegate.m */, 128 | B66154291BE9952400FC9689 /* ViewController.h */, 129 | B661542A1BE9952400FC9689 /* ViewController.m */, 130 | B66154561BE9953100FC9689 /* selectCity */, 131 | B661542C1BE9952400FC9689 /* Main.storyboard */, 132 | B661542F1BE9952400FC9689 /* Assets.xcassets */, 133 | B66154311BE9952400FC9689 /* LaunchScreen.storyboard */, 134 | B66154341BE9952400FC9689 /* Info.plist */, 135 | B66154231BE9952400FC9689 /* Supporting Files */, 136 | ); 137 | path = SelectCityDemo; 138 | sourceTree = ""; 139 | }; 140 | B66154231BE9952400FC9689 /* Supporting Files */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | B66154241BE9952400FC9689 /* main.m */, 144 | ); 145 | name = "Supporting Files"; 146 | sourceTree = ""; 147 | }; 148 | B661543C1BE9952400FC9689 /* SelectCityDemoTests */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | B661543D1BE9952400FC9689 /* SelectCityDemoTests.m */, 152 | B661543F1BE9952400FC9689 /* Info.plist */, 153 | ); 154 | path = SelectCityDemoTests; 155 | sourceTree = ""; 156 | }; 157 | B66154471BE9952400FC9689 /* SelectCityDemoUITests */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | B66154481BE9952400FC9689 /* SelectCityDemoUITests.m */, 161 | B661544A1BE9952400FC9689 /* Info.plist */, 162 | ); 163 | path = SelectCityDemoUITests; 164 | sourceTree = ""; 165 | }; 166 | B66154561BE9953100FC9689 /* selectCity */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | B66154571BE9953100FC9689 /* cancelBtn@2x.png */, 170 | B66154581BE9953100FC9689 /* citydict.plist */, 171 | B66154591BE9953100FC9689 /* Controller */, 172 | B661545E1BE9953100FC9689 /* Model */, 173 | B66154611BE9953100FC9689 /* View */, 174 | ); 175 | path = selectCity; 176 | sourceTree = ""; 177 | }; 178 | B66154591BE9953100FC9689 /* Controller */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | B661545A1BE9953100FC9689 /* CityViewController.h */, 182 | B661545B1BE9953100FC9689 /* CityViewController.m */, 183 | B661545C1BE9953100FC9689 /* ResultCityController.h */, 184 | B661545D1BE9953100FC9689 /* ResultCityController.m */, 185 | ); 186 | path = Controller; 187 | sourceTree = ""; 188 | }; 189 | B661545E1BE9953100FC9689 /* Model */ = { 190 | isa = PBXGroup; 191 | children = ( 192 | B661545F1BE9953100FC9689 /* CityModel.h */, 193 | B66154601BE9953100FC9689 /* CityModel.m */, 194 | ); 195 | path = Model; 196 | sourceTree = ""; 197 | }; 198 | B66154611BE9953100FC9689 /* View */ = { 199 | isa = PBXGroup; 200 | children = ( 201 | B66154701BE996A600FC9689 /* CustomSearchView.h */, 202 | B66154711BE996A600FC9689 /* CustomSearchView.m */, 203 | B66154621BE9953100FC9689 /* CityTableViewCell.h */, 204 | B66154631BE9953100FC9689 /* CityTableViewCell.m */, 205 | B66154641BE9953100FC9689 /* CustomTopView.h */, 206 | B66154651BE9953100FC9689 /* CustomTopView.m */, 207 | ); 208 | path = View; 209 | sourceTree = ""; 210 | }; 211 | /* End PBXGroup section */ 212 | 213 | /* Begin PBXNativeTarget section */ 214 | B661541F1BE9952400FC9689 /* SelectCityDemo */ = { 215 | isa = PBXNativeTarget; 216 | buildConfigurationList = B661544D1BE9952400FC9689 /* Build configuration list for PBXNativeTarget "SelectCityDemo" */; 217 | buildPhases = ( 218 | B661541C1BE9952400FC9689 /* Sources */, 219 | B661541D1BE9952400FC9689 /* Frameworks */, 220 | B661541E1BE9952400FC9689 /* Resources */, 221 | ); 222 | buildRules = ( 223 | ); 224 | dependencies = ( 225 | ); 226 | name = SelectCityDemo; 227 | productName = SelectCityDemo; 228 | productReference = B66154201BE9952400FC9689 /* SelectCityDemo.app */; 229 | productType = "com.apple.product-type.application"; 230 | }; 231 | B66154381BE9952400FC9689 /* SelectCityDemoTests */ = { 232 | isa = PBXNativeTarget; 233 | buildConfigurationList = B66154501BE9952400FC9689 /* Build configuration list for PBXNativeTarget "SelectCityDemoTests" */; 234 | buildPhases = ( 235 | B66154351BE9952400FC9689 /* Sources */, 236 | B66154361BE9952400FC9689 /* Frameworks */, 237 | B66154371BE9952400FC9689 /* Resources */, 238 | ); 239 | buildRules = ( 240 | ); 241 | dependencies = ( 242 | B661543B1BE9952400FC9689 /* PBXTargetDependency */, 243 | ); 244 | name = SelectCityDemoTests; 245 | productName = SelectCityDemoTests; 246 | productReference = B66154391BE9952400FC9689 /* SelectCityDemoTests.xctest */; 247 | productType = "com.apple.product-type.bundle.unit-test"; 248 | }; 249 | B66154431BE9952400FC9689 /* SelectCityDemoUITests */ = { 250 | isa = PBXNativeTarget; 251 | buildConfigurationList = B66154531BE9952400FC9689 /* Build configuration list for PBXNativeTarget "SelectCityDemoUITests" */; 252 | buildPhases = ( 253 | B66154401BE9952400FC9689 /* Sources */, 254 | B66154411BE9952400FC9689 /* Frameworks */, 255 | B66154421BE9952400FC9689 /* Resources */, 256 | ); 257 | buildRules = ( 258 | ); 259 | dependencies = ( 260 | B66154461BE9952400FC9689 /* PBXTargetDependency */, 261 | ); 262 | name = SelectCityDemoUITests; 263 | productName = SelectCityDemoUITests; 264 | productReference = B66154441BE9952400FC9689 /* SelectCityDemoUITests.xctest */; 265 | productType = "com.apple.product-type.bundle.ui-testing"; 266 | }; 267 | /* End PBXNativeTarget section */ 268 | 269 | /* Begin PBXProject section */ 270 | B66154181BE9952400FC9689 /* Project object */ = { 271 | isa = PBXProject; 272 | attributes = { 273 | LastUpgradeCheck = 0710; 274 | ORGANIZATIONNAME = WXDL; 275 | TargetAttributes = { 276 | B661541F1BE9952400FC9689 = { 277 | CreatedOnToolsVersion = 7.1; 278 | }; 279 | B66154381BE9952400FC9689 = { 280 | CreatedOnToolsVersion = 7.1; 281 | TestTargetID = B661541F1BE9952400FC9689; 282 | }; 283 | B66154431BE9952400FC9689 = { 284 | CreatedOnToolsVersion = 7.1; 285 | TestTargetID = B661541F1BE9952400FC9689; 286 | }; 287 | }; 288 | }; 289 | buildConfigurationList = B661541B1BE9952400FC9689 /* Build configuration list for PBXProject "SelectCityDemo" */; 290 | compatibilityVersion = "Xcode 3.2"; 291 | developmentRegion = English; 292 | hasScannedForEncodings = 0; 293 | knownRegions = ( 294 | en, 295 | Base, 296 | ); 297 | mainGroup = B66154171BE9952400FC9689; 298 | productRefGroup = B66154211BE9952400FC9689 /* Products */; 299 | projectDirPath = ""; 300 | projectRoot = ""; 301 | targets = ( 302 | B661541F1BE9952400FC9689 /* SelectCityDemo */, 303 | B66154381BE9952400FC9689 /* SelectCityDemoTests */, 304 | B66154431BE9952400FC9689 /* SelectCityDemoUITests */, 305 | ); 306 | }; 307 | /* End PBXProject section */ 308 | 309 | /* Begin PBXResourcesBuildPhase section */ 310 | B661541E1BE9952400FC9689 /* Resources */ = { 311 | isa = PBXResourcesBuildPhase; 312 | buildActionMask = 2147483647; 313 | files = ( 314 | B66154671BE9953100FC9689 /* citydict.plist in Resources */, 315 | B66154331BE9952400FC9689 /* LaunchScreen.storyboard in Resources */, 316 | B66154301BE9952400FC9689 /* Assets.xcassets in Resources */, 317 | B661542E1BE9952400FC9689 /* Main.storyboard in Resources */, 318 | B66154661BE9953100FC9689 /* cancelBtn@2x.png in Resources */, 319 | ); 320 | runOnlyForDeploymentPostprocessing = 0; 321 | }; 322 | B66154371BE9952400FC9689 /* Resources */ = { 323 | isa = PBXResourcesBuildPhase; 324 | buildActionMask = 2147483647; 325 | files = ( 326 | ); 327 | runOnlyForDeploymentPostprocessing = 0; 328 | }; 329 | B66154421BE9952400FC9689 /* Resources */ = { 330 | isa = PBXResourcesBuildPhase; 331 | buildActionMask = 2147483647; 332 | files = ( 333 | ); 334 | runOnlyForDeploymentPostprocessing = 0; 335 | }; 336 | /* End PBXResourcesBuildPhase section */ 337 | 338 | /* Begin PBXSourcesBuildPhase section */ 339 | B661541C1BE9952400FC9689 /* Sources */ = { 340 | isa = PBXSourcesBuildPhase; 341 | buildActionMask = 2147483647; 342 | files = ( 343 | B661546B1BE9953100FC9689 /* CityTableViewCell.m in Sources */, 344 | B66154691BE9953100FC9689 /* ResultCityController.m in Sources */, 345 | B661542B1BE9952400FC9689 /* ViewController.m in Sources */, 346 | B661546C1BE9953100FC9689 /* CustomTopView.m in Sources */, 347 | B66154281BE9952400FC9689 /* AppDelegate.m in Sources */, 348 | B66154721BE996A600FC9689 /* CustomSearchView.m in Sources */, 349 | B66154251BE9952400FC9689 /* main.m in Sources */, 350 | B661546A1BE9953100FC9689 /* CityModel.m in Sources */, 351 | B66154681BE9953100FC9689 /* CityViewController.m in Sources */, 352 | ); 353 | runOnlyForDeploymentPostprocessing = 0; 354 | }; 355 | B66154351BE9952400FC9689 /* Sources */ = { 356 | isa = PBXSourcesBuildPhase; 357 | buildActionMask = 2147483647; 358 | files = ( 359 | B661543E1BE9952400FC9689 /* SelectCityDemoTests.m in Sources */, 360 | ); 361 | runOnlyForDeploymentPostprocessing = 0; 362 | }; 363 | B66154401BE9952400FC9689 /* Sources */ = { 364 | isa = PBXSourcesBuildPhase; 365 | buildActionMask = 2147483647; 366 | files = ( 367 | B66154491BE9952400FC9689 /* SelectCityDemoUITests.m in Sources */, 368 | ); 369 | runOnlyForDeploymentPostprocessing = 0; 370 | }; 371 | /* End PBXSourcesBuildPhase section */ 372 | 373 | /* Begin PBXTargetDependency section */ 374 | B661543B1BE9952400FC9689 /* PBXTargetDependency */ = { 375 | isa = PBXTargetDependency; 376 | target = B661541F1BE9952400FC9689 /* SelectCityDemo */; 377 | targetProxy = B661543A1BE9952400FC9689 /* PBXContainerItemProxy */; 378 | }; 379 | B66154461BE9952400FC9689 /* PBXTargetDependency */ = { 380 | isa = PBXTargetDependency; 381 | target = B661541F1BE9952400FC9689 /* SelectCityDemo */; 382 | targetProxy = B66154451BE9952400FC9689 /* PBXContainerItemProxy */; 383 | }; 384 | /* End PBXTargetDependency section */ 385 | 386 | /* Begin PBXVariantGroup section */ 387 | B661542C1BE9952400FC9689 /* Main.storyboard */ = { 388 | isa = PBXVariantGroup; 389 | children = ( 390 | B661542D1BE9952400FC9689 /* Base */, 391 | ); 392 | name = Main.storyboard; 393 | sourceTree = ""; 394 | }; 395 | B66154311BE9952400FC9689 /* LaunchScreen.storyboard */ = { 396 | isa = PBXVariantGroup; 397 | children = ( 398 | B66154321BE9952400FC9689 /* Base */, 399 | ); 400 | name = LaunchScreen.storyboard; 401 | sourceTree = ""; 402 | }; 403 | /* End PBXVariantGroup section */ 404 | 405 | /* Begin XCBuildConfiguration section */ 406 | B661544B1BE9952400FC9689 /* Debug */ = { 407 | isa = XCBuildConfiguration; 408 | buildSettings = { 409 | ALWAYS_SEARCH_USER_PATHS = NO; 410 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 411 | CLANG_CXX_LIBRARY = "libc++"; 412 | CLANG_ENABLE_MODULES = YES; 413 | CLANG_ENABLE_OBJC_ARC = YES; 414 | CLANG_WARN_BOOL_CONVERSION = YES; 415 | CLANG_WARN_CONSTANT_CONVERSION = YES; 416 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 417 | CLANG_WARN_EMPTY_BODY = YES; 418 | CLANG_WARN_ENUM_CONVERSION = YES; 419 | CLANG_WARN_INT_CONVERSION = YES; 420 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 421 | CLANG_WARN_UNREACHABLE_CODE = YES; 422 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 423 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 424 | COPY_PHASE_STRIP = NO; 425 | DEBUG_INFORMATION_FORMAT = dwarf; 426 | ENABLE_STRICT_OBJC_MSGSEND = YES; 427 | ENABLE_TESTABILITY = YES; 428 | GCC_C_LANGUAGE_STANDARD = gnu99; 429 | GCC_DYNAMIC_NO_PIC = NO; 430 | GCC_NO_COMMON_BLOCKS = YES; 431 | GCC_OPTIMIZATION_LEVEL = 0; 432 | GCC_PREPROCESSOR_DEFINITIONS = ( 433 | "DEBUG=1", 434 | "$(inherited)", 435 | ); 436 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 437 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 438 | GCC_WARN_UNDECLARED_SELECTOR = YES; 439 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 440 | GCC_WARN_UNUSED_FUNCTION = YES; 441 | GCC_WARN_UNUSED_VARIABLE = YES; 442 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 443 | MTL_ENABLE_DEBUG_INFO = YES; 444 | ONLY_ACTIVE_ARCH = YES; 445 | SDKROOT = iphoneos; 446 | }; 447 | name = Debug; 448 | }; 449 | B661544C1BE9952400FC9689 /* Release */ = { 450 | isa = XCBuildConfiguration; 451 | buildSettings = { 452 | ALWAYS_SEARCH_USER_PATHS = NO; 453 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 454 | CLANG_CXX_LIBRARY = "libc++"; 455 | CLANG_ENABLE_MODULES = YES; 456 | CLANG_ENABLE_OBJC_ARC = YES; 457 | CLANG_WARN_BOOL_CONVERSION = YES; 458 | CLANG_WARN_CONSTANT_CONVERSION = YES; 459 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 460 | CLANG_WARN_EMPTY_BODY = YES; 461 | CLANG_WARN_ENUM_CONVERSION = YES; 462 | CLANG_WARN_INT_CONVERSION = YES; 463 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 464 | CLANG_WARN_UNREACHABLE_CODE = YES; 465 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 466 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 467 | COPY_PHASE_STRIP = NO; 468 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 469 | ENABLE_NS_ASSERTIONS = NO; 470 | ENABLE_STRICT_OBJC_MSGSEND = YES; 471 | GCC_C_LANGUAGE_STANDARD = gnu99; 472 | GCC_NO_COMMON_BLOCKS = YES; 473 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 474 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 475 | GCC_WARN_UNDECLARED_SELECTOR = YES; 476 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 477 | GCC_WARN_UNUSED_FUNCTION = YES; 478 | GCC_WARN_UNUSED_VARIABLE = YES; 479 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 480 | MTL_ENABLE_DEBUG_INFO = NO; 481 | SDKROOT = iphoneos; 482 | VALIDATE_PRODUCT = YES; 483 | }; 484 | name = Release; 485 | }; 486 | B661544E1BE9952400FC9689 /* Debug */ = { 487 | isa = XCBuildConfiguration; 488 | buildSettings = { 489 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 490 | INFOPLIST_FILE = SelectCityDemo/Info.plist; 491 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 492 | PRODUCT_BUNDLE_IDENTIFIER = com.WXDL.SelectCityDemo; 493 | PRODUCT_NAME = "$(TARGET_NAME)"; 494 | TARGETED_DEVICE_FAMILY = "1,2"; 495 | }; 496 | name = Debug; 497 | }; 498 | B661544F1BE9952400FC9689 /* Release */ = { 499 | isa = XCBuildConfiguration; 500 | buildSettings = { 501 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 502 | INFOPLIST_FILE = SelectCityDemo/Info.plist; 503 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 504 | PRODUCT_BUNDLE_IDENTIFIER = com.WXDL.SelectCityDemo; 505 | PRODUCT_NAME = "$(TARGET_NAME)"; 506 | TARGETED_DEVICE_FAMILY = "1,2"; 507 | }; 508 | name = Release; 509 | }; 510 | B66154511BE9952400FC9689 /* Debug */ = { 511 | isa = XCBuildConfiguration; 512 | buildSettings = { 513 | BUNDLE_LOADER = "$(TEST_HOST)"; 514 | INFOPLIST_FILE = SelectCityDemoTests/Info.plist; 515 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 516 | PRODUCT_BUNDLE_IDENTIFIER = com.WXDL.SelectCityDemoTests; 517 | PRODUCT_NAME = "$(TARGET_NAME)"; 518 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SelectCityDemo.app/SelectCityDemo"; 519 | }; 520 | name = Debug; 521 | }; 522 | B66154521BE9952400FC9689 /* Release */ = { 523 | isa = XCBuildConfiguration; 524 | buildSettings = { 525 | BUNDLE_LOADER = "$(TEST_HOST)"; 526 | INFOPLIST_FILE = SelectCityDemoTests/Info.plist; 527 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 528 | PRODUCT_BUNDLE_IDENTIFIER = com.WXDL.SelectCityDemoTests; 529 | PRODUCT_NAME = "$(TARGET_NAME)"; 530 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SelectCityDemo.app/SelectCityDemo"; 531 | }; 532 | name = Release; 533 | }; 534 | B66154541BE9952400FC9689 /* Debug */ = { 535 | isa = XCBuildConfiguration; 536 | buildSettings = { 537 | INFOPLIST_FILE = SelectCityDemoUITests/Info.plist; 538 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 539 | PRODUCT_BUNDLE_IDENTIFIER = com.WXDL.SelectCityDemoUITests; 540 | PRODUCT_NAME = "$(TARGET_NAME)"; 541 | TEST_TARGET_NAME = SelectCityDemo; 542 | USES_XCTRUNNER = YES; 543 | }; 544 | name = Debug; 545 | }; 546 | B66154551BE9952400FC9689 /* Release */ = { 547 | isa = XCBuildConfiguration; 548 | buildSettings = { 549 | INFOPLIST_FILE = SelectCityDemoUITests/Info.plist; 550 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 551 | PRODUCT_BUNDLE_IDENTIFIER = com.WXDL.SelectCityDemoUITests; 552 | PRODUCT_NAME = "$(TARGET_NAME)"; 553 | TEST_TARGET_NAME = SelectCityDemo; 554 | USES_XCTRUNNER = YES; 555 | }; 556 | name = Release; 557 | }; 558 | /* End XCBuildConfiguration section */ 559 | 560 | /* Begin XCConfigurationList section */ 561 | B661541B1BE9952400FC9689 /* Build configuration list for PBXProject "SelectCityDemo" */ = { 562 | isa = XCConfigurationList; 563 | buildConfigurations = ( 564 | B661544B1BE9952400FC9689 /* Debug */, 565 | B661544C1BE9952400FC9689 /* Release */, 566 | ); 567 | defaultConfigurationIsVisible = 0; 568 | defaultConfigurationName = Release; 569 | }; 570 | B661544D1BE9952400FC9689 /* Build configuration list for PBXNativeTarget "SelectCityDemo" */ = { 571 | isa = XCConfigurationList; 572 | buildConfigurations = ( 573 | B661544E1BE9952400FC9689 /* Debug */, 574 | B661544F1BE9952400FC9689 /* Release */, 575 | ); 576 | defaultConfigurationIsVisible = 0; 577 | defaultConfigurationName = Release; 578 | }; 579 | B66154501BE9952400FC9689 /* Build configuration list for PBXNativeTarget "SelectCityDemoTests" */ = { 580 | isa = XCConfigurationList; 581 | buildConfigurations = ( 582 | B66154511BE9952400FC9689 /* Debug */, 583 | B66154521BE9952400FC9689 /* Release */, 584 | ); 585 | defaultConfigurationIsVisible = 0; 586 | defaultConfigurationName = Release; 587 | }; 588 | B66154531BE9952400FC9689 /* Build configuration list for PBXNativeTarget "SelectCityDemoUITests" */ = { 589 | isa = XCConfigurationList; 590 | buildConfigurations = ( 591 | B66154541BE9952400FC9689 /* Debug */, 592 | B66154551BE9952400FC9689 /* Release */, 593 | ); 594 | defaultConfigurationIsVisible = 0; 595 | defaultConfigurationName = Release; 596 | }; 597 | /* End XCConfigurationList section */ 598 | }; 599 | rootObject = B66154181BE9952400FC9689 /* Project object */; 600 | } 601 | -------------------------------------------------------------------------------- /SelectCityDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SelectCityDemo.xcodeproj/xcuserdata/ZJ.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /SelectCityDemo.xcodeproj/xcuserdata/ZJ.xcuserdatad/xcschemes/SelectCityDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /SelectCityDemo.xcodeproj/xcuserdata/ZJ.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SelectCityDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | B661541F1BE9952400FC9689 16 | 17 | primary 18 | 19 | 20 | B66154381BE9952400FC9689 21 | 22 | primary 23 | 24 | 25 | B66154431BE9952400FC9689 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /SelectCityDemo.xcodeproj/xcuserdata/liyang.xcuserdatad/xcschemes/SelectCityDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /SelectCityDemo.xcodeproj/xcuserdata/liyang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SelectCityDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | B661541F1BE9952400FC9689 16 | 17 | primary 18 | 19 | 20 | B66154381BE9952400FC9689 21 | 22 | primary 23 | 24 | 25 | B66154431BE9952400FC9689 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /SelectCityDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SelectCityDemo 4 | // 5 | // Created by ZJ on 15/11/4. 6 | // Copyright © 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /SelectCityDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SelectCityDemo 4 | // 5 | // Created by ZJ on 15/11/4. 6 | // Copyright © 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // 自己实现的城市列表选择界面 20 | // Override point for customization after application launch. 21 | return YES; 22 | } 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // 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. 27 | } 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application { 30 | // 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. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | - (void)applicationWillEnterForeground:(UIApplication *)application { 35 | // 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. 36 | } 37 | 38 | - (void)applicationDidBecomeActive:(UIApplication *)application { 39 | // 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. 40 | } 41 | 42 | - (void)applicationWillTerminate:(UIApplication *)application { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /SelectCityDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /SelectCityDemo/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 | -------------------------------------------------------------------------------- /SelectCityDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 31 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /SelectCityDemo/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /SelectCityDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SelectCityDemo 4 | // 5 | // Created by ZJ on 15/11/4. 6 | // Copyright © 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SelectCityDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SelectCityDemo 4 | // 5 | // Created by ZJ on 15/11/4. 6 | // Copyright © 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "CityViewController.h" 11 | @interface ViewController () 12 | 13 | @property (weak, nonatomic) IBOutlet UILabel *cityLabel; 14 | 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad 20 | { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view, typically from a nib. 23 | } 24 | - (IBAction)click:(id)sender 25 | { 26 | 27 | CityViewController *controller = [[CityViewController alloc] init]; 28 | controller.currentCityString = @"杭州"; 29 | controller.selectString = ^(NSString *string){ 30 | self.cityLabel.text = string; 31 | }; 32 | [self presentViewController:controller animated:YES completion:nil]; 33 | } 34 | 35 | - (void)didReceiveMemoryWarning { 36 | [super didReceiveMemoryWarning]; 37 | // Dispose of any resources that can be recreated. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /SelectCityDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SelectCityDemo 4 | // 5 | // Created by ZJ on 15/11/4. 6 | // Copyright © 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/Controller/CityViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CityViewController.h 3 | // MySelectCityDemo 4 | // 5 | // Created by 李阳 on 15/9/1. 6 | // Copyright (c) 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import 10 | @interface CityViewController : UIViewController 11 | { 12 | UITableView *_tableView; 13 | } 14 | @property (nonatomic,copy)void(^selectString)(NSString *string); 15 | @property (nonatomic,copy)NSString *currentCityString; 16 | @end 17 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/Controller/CityViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CityViewController.m 3 | // MySelectCityDemo 4 | // 5 | // Created by 李阳 on 15/9/1. 6 | // Copyright (c) 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import "CityViewController.h" 10 | #import "CustomTopView.h" 11 | #import "CustomSearchView.h" 12 | #import "ResultCityController.h" 13 | #import "CityModel.h" 14 | #import "CityTableViewCell.h" 15 | #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) 16 | #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) 17 | @interface CityViewController () 18 | @property (nonatomic,retain) CustomTopView *navView; //自定义导航栏 19 | @property (nonatomic,retain) CustomSearchView *searchView; //searchBar所在的view 20 | @property (nonatomic,retain)UIView *blackView; //输入框编辑时的黑色背景view 21 | @property (nonatomic,retain)NSDictionary *bigDic; // 读取本地plist文件的字典 22 | @property (nonatomic,retain)NSMutableArray *sectionTitlesArray; // 区头数组 23 | @property (nonatomic,retain)NSMutableArray *rightIndexArray; // 右边索引数组 24 | @property (nonatomic,retain)NSMutableArray *dataArray;// cell数据源数组 25 | @property (nonatomic,retain)NSMutableArray *searchArray;//用于搜索的数组 26 | @property (nonatomic,retain)NSMutableArray *pinYinArray; // 地区名字转化为拼音的数组 27 | @property (nonatomic,retain)ResultCityController *resultController;//显示结果的controller 28 | @property (nonatomic,retain)NSArray *currentCityArray;// 当前城市 29 | @property (nonatomic,retain)NSArray *hotCityArray; // 热门城市 30 | @end 31 | 32 | @implementation CityViewController 33 | 34 | -(UIView *)blackView 35 | { 36 | if(!_blackView) 37 | { 38 | _blackView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64)]; 39 | _blackView.backgroundColor = [UIColor colorWithRed:60/255.0 green:60/255.0 blue:60/255.0 alpha:0.6]; 40 | _blackView.alpha = 0; 41 | [self.view addSubview:_blackView]; 42 | UITapGestureRecognizer *ges = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didSelectCancelBtn)]; 43 | [_blackView addGestureRecognizer:ges]; 44 | } 45 | return _blackView; 46 | } 47 | -(ResultCityController *)resultController 48 | { 49 | if(!_resultController) 50 | { 51 | _resultController = [[ResultCityController alloc] init]; 52 | 53 | _resultController.view.frame = CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64); 54 | _resultController.delegate = self; 55 | [self.view addSubview:_resultController.view]; 56 | } 57 | return _resultController; 58 | } 59 | - (void)viewDidLoad { 60 | [super viewDidLoad]; 61 | 62 | self.view.backgroundColor = [UIColor whiteColor]; 63 | [self loadData]; 64 | 65 | self.searchView = [[CustomSearchView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-20, 44)]; 66 | _searchView.delegate = self; 67 | _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64) style:UITableViewStylePlain]; 68 | _tableView.backgroundColor = [UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1]; 69 | _tableView.delegate = self; 70 | _tableView.dataSource = self; 71 | _tableView.tableHeaderView = _searchView; 72 | _tableView.showsVerticalScrollIndicator = NO; 73 | _tableView.sectionIndexColor = [UIColor redColor]; 74 | [self.view addSubview:_tableView]; 75 | 76 | self.navView = [[CustomTopView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64)]; 77 | _navView.delegate = self; 78 | [self.view addSubview:_navView]; 79 | 80 | 81 | } 82 | #pragma mark --UITableViewDelegate 83 | -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 84 | { 85 | return self.sectionTitlesArray.count; 86 | } 87 | -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 88 | { 89 | if (section==0||section==1) 90 | { 91 | return 1; 92 | } 93 | else 94 | { 95 | return [self.dataArray[section] count]; 96 | } 97 | 98 | } 99 | -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 100 | { 101 | static NSString *HeaderIdentifier = @"header"; 102 | UITableViewHeaderFooterView * headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:HeaderIdentifier]; 103 | if( headerView == nil) 104 | { 105 | headerView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:HeaderIdentifier]; 106 | UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 80, 25)]; 107 | titleLabel.tag = 1; 108 | titleLabel.backgroundColor = [UIColor clearColor]; 109 | titleLabel.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1]; 110 | [headerView.contentView addSubview:titleLabel]; 111 | } 112 | headerView.contentView.backgroundColor = [UIColor colorWithRed:235/255.0 green:235/255.0 blue:235/255.0 alpha:1]; 113 | UILabel *label = (UILabel *)[headerView viewWithTag:1]; 114 | label.text = self.sectionTitlesArray[section]; 115 | return headerView; 116 | } 117 | -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 118 | { 119 | if(indexPath.section==0) 120 | { 121 | return 60; 122 | } 123 | else if (indexPath.section==1) 124 | { 125 | return 150; 126 | } 127 | else 128 | { 129 | return 44; 130 | } 131 | } 132 | -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 133 | { 134 | return CGFLOAT_MIN ; 135 | } 136 | -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 137 | { 138 | return 25; 139 | } 140 | -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 141 | { 142 | if(indexPath.section<2) 143 | { 144 | __weak typeof(self) weakSelf = self; 145 | CityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cityCell"]; 146 | if(cell==nil) 147 | { 148 | cell = [[CityTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cityCell" cityArray:self.dataArray[indexPath.section]]; 149 | } 150 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 151 | cell.didSelectedBtn = ^(int tag){ 152 | if(tag==1111) 153 | { 154 | weakSelf.selectString(weakSelf.currentCityString); 155 | 156 | } 157 | else 158 | { 159 | weakSelf.selectString(weakSelf.hotCityArray[tag]); 160 | } 161 | [weakSelf dismissViewControllerAnimated:YES completion:nil]; 162 | }; 163 | 164 | return cell; 165 | } 166 | else 167 | { 168 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 169 | if(cell==nil) 170 | { 171 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 172 | } 173 | NSArray *array = self.dataArray[indexPath.section]; 174 | cell.textLabel.text = array[indexPath.row]; 175 | cell.textLabel.font = [UIFont systemFontOfSize:16]; 176 | cell.textLabel.textColor = [UIColor colorWithRed:54/255.0 green:54/255.0 blue:54/255.0 alpha:1]; 177 | return cell; 178 | } 179 | return nil; 180 | } 181 | - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView 182 | { 183 | 184 | if(_blackView) 185 | { 186 | return nil; 187 | } 188 | else 189 | { 190 | 191 | return self.rightIndexArray; 192 | } 193 | 194 | } 195 | -(NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index 196 | { 197 | //此方法返回的是section的值 198 | NSLog(@"%d",(int)index); 199 | if(index==0) 200 | { 201 | [tableView setContentOffset:CGPointZero animated:YES]; 202 | 203 | return -1; 204 | } 205 | else 206 | { 207 | return index+1; 208 | } 209 | } 210 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 211 | { 212 | if(indexPath.section==0) 213 | { 214 | 215 | 216 | } 217 | else if(indexPath.section==1) 218 | { 219 | 220 | } 221 | else 222 | { 223 | NSString *string = self.dataArray[indexPath.section][indexPath.row]; 224 | self.selectString(string); 225 | [self dismissViewControllerAnimated:YES completion:nil]; 226 | } 227 | 228 | } 229 | #pragma mark --CustomTopViewDelegate 230 | -(void)didSelectBackButton 231 | { 232 | [self dismissViewControllerAnimated:YES completion:nil]; 233 | } 234 | #pragma mark --CustomSearchViewDelegate 235 | -(void)searchString:(NSString *)string 236 | { 237 | 238 | // ”^[A-Za-z]+$” 239 | NSMutableArray *resultArray = [NSMutableArray array]; 240 | if([self isZimuWithstring:string]) 241 | { 242 | //证明输入的是字母 243 | self.pinYinArray = [NSMutableArray array]; //和输入的拼音首字母相同的地区的拼音 244 | NSString *upperCaseString2 = string.uppercaseString; 245 | NSString *firstString = [upperCaseString2 substringToIndex:1]; 246 | NSArray *array = [self.bigDic objectForKey:firstString]; 247 | [array enumerateObjectsUsingBlock:^(NSString *cityName, NSUInteger idx, BOOL * _Nonnull stop) { 248 | CityModel *model = [[CityModel alloc] init]; 249 | NSString *pinYin = [self Charactor:cityName getFirstCharactor:NO]; 250 | model.name = cityName; 251 | model.pinYinName = pinYin; 252 | [self.pinYinArray addObject:model]; 253 | }]; 254 | NSPredicate *pred = [NSPredicate predicateWithFormat:@"pinYinName BEGINSWITH[c] %@",string]; 255 | NSArray *smallArray = [self.pinYinArray filteredArrayUsingPredicate:pred]; 256 | [smallArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 257 | CityModel *model = obj; 258 | [resultArray addObject:model.name]; 259 | }]; 260 | } 261 | else 262 | { 263 | //证明输入的是汉字 264 | [self.searchArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 265 | NSArray *sectionArray = obj; 266 | NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH[c] %@",string]; 267 | NSArray *array = [sectionArray filteredArrayUsingPredicate:pred]; 268 | [resultArray addObjectsFromArray:array]; 269 | }]; 270 | } 271 | self.resultController.dataArray = resultArray; 272 | [self.resultController.tableView reloadData]; 273 | } 274 | -(void)searchBeginEditing 275 | { 276 | [self.view addSubview:_blackView]; 277 | 278 | [UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{ 279 | 280 | self.navView.frame = CGRectMake(0, -64, SCREEN_WIDTH, 64); 281 | _tableView.frame = CGRectMake(0, 20, SCREEN_WIDTH, SCREEN_HEIGHT); 282 | self.blackView.alpha = 0.6; 283 | 284 | } completion:^(BOOL finished) { 285 | UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 20)]; 286 | view1.tag = 333; 287 | view1.backgroundColor = [UIColor colorWithRed:220/255.0 green:220/255.0 blue:220/255.0 alpha:1]; 288 | [self.view addSubview:view1]; 289 | 290 | }]; 291 | [_tableView reloadData]; 292 | } 293 | -(void)didSelectCancelBtn 294 | { 295 | UIView *view1 = (UIView *)[self.view viewWithTag:333]; 296 | [view1 removeFromSuperview]; 297 | [_blackView removeFromSuperview]; 298 | _blackView = nil; 299 | [self.resultController.view removeFromSuperview]; 300 | self.resultController=nil; 301 | [UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{ 302 | 303 | self.navView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 64); 304 | _tableView.frame = CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64); 305 | 306 | [self.searchView.searchBar setShowsCancelButton:NO animated:YES]; 307 | [self.searchView.searchBar resignFirstResponder]; 308 | 309 | } completion:^(BOOL finished) { 310 | }]; 311 | [_tableView reloadData]; 312 | } 313 | #pragma mark --ResultCityControllerDelegate 314 | -(void)didScroll 315 | { 316 | [self.searchView.searchBar resignFirstResponder]; 317 | } 318 | -(void)didSelectedString:(NSString *)string 319 | { 320 | self.selectString(string); 321 | [self dismissViewControllerAnimated:YES completion:nil]; 322 | } 323 | -(void)loadData 324 | { 325 | self.rightIndexArray = [NSMutableArray array]; 326 | self.sectionTitlesArray = [NSMutableArray array]; //区头字母数组 327 | self.dataArray = [NSMutableArray array]; //包含所有区数组的大数组 328 | self.searchArray = [NSMutableArray array]; 329 | NSString *path=[[NSBundle mainBundle] pathForResource:@"citydict" 330 | ofType:@"plist"]; 331 | self.bigDic = [[NSDictionary alloc] initWithContentsOfFile:path]; 332 | NSArray * allKeys = [self.bigDic allKeys]; 333 | [self.sectionTitlesArray addObjectsFromArray:[allKeys sortedArrayUsingSelector:@selector(compare:)]]; 334 | [self.sectionTitlesArray enumerateObjectsUsingBlock:^(NSString *zimu, NSUInteger idx, BOOL * _Nonnull stop) { 335 | NSArray *smallArray = self.bigDic[zimu]; 336 | [self.dataArray addObject:smallArray]; 337 | [self.searchArray addObject:smallArray]; 338 | }]; 339 | [self.rightIndexArray addObjectsFromArray:self.sectionTitlesArray]; 340 | [self.rightIndexArray insertObject:UITableViewIndexSearch atIndex:0]; 341 | [self.sectionTitlesArray insertObject:@"热门城市" atIndex:0]; 342 | [self.sectionTitlesArray insertObject:@"定位城市" atIndex:0]; 343 | self.currentCityArray = @[self.currentCityString]; 344 | self.hotCityArray = @[@"上海",@"北京",@"广州",@"深圳",@"武汉",@"天津",@"西安",@"南京",@"杭州"]; 345 | [self.dataArray insertObject:self.hotCityArray atIndex:0]; 346 | [self.dataArray insertObject:self.currentCityArray atIndex:0]; 347 | } 348 | - (NSString *)Charactor:(NSString *)aString getFirstCharactor:(BOOL)isGetFirst 349 | { 350 | //转成了可变字符串 351 | NSMutableString *str = [NSMutableString stringWithString:aString]; 352 | //先转换为带声调的拼音 353 | CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformMandarinLatin,NO); 354 | //再转换为不带声调的拼音 355 | CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformMandarinLatin,NO); 356 | CFStringTransform((CFMutableStringRef)str, NULL, kCFStringTransformStripDiacritics, NO); 357 | NSString *pinYin = [str capitalizedString]; 358 | //转化为大写拼音 359 | if(isGetFirst) 360 | { 361 | //获取并返回首字母 362 | return [pinYin substringToIndex:1]; 363 | } 364 | else 365 | { 366 | return pinYin; 367 | } 368 | } 369 | -(BOOL)isZimuWithstring:(NSString *)string 370 | { 371 | NSString* number=@"^[A-Za-z]+$"; 372 | NSPredicate *numberPre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",number]; 373 | return [numberPre evaluateWithObject:string]; 374 | } 375 | @end 376 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/Controller/ResultCityController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ResultCityController.h 3 | // MySelectCityDemo 4 | // 5 | // Created by 李阳 on 15/9/2. 6 | // Copyright (c) 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol ResultCityControllerDelegate 12 | 13 | -(void)didScroll; 14 | -(void)didSelectedString:(NSString *)string; 15 | 16 | @end 17 | 18 | @interface ResultCityController : UIViewController 19 | 20 | @property (nonatomic,retain)NSMutableArray *dataArray; 21 | @property (nonatomic,retain)UITableView *tableView; 22 | @property (nonatomic,assign) id delegate; 23 | @end 24 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/Controller/ResultCityController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ResultCityController.m 3 | // MySelectCityDemo 4 | // 5 | // Created by 李阳 on 15/9/2. 6 | // Copyright (c) 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import "ResultCityController.h" 10 | 11 | @implementation ResultCityController 12 | -(UITableView *)tableView 13 | { 14 | if(!_tableView) 15 | { 16 | _tableView =[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; 17 | _tableView.delegate = self; 18 | _tableView.dataSource = self; 19 | _tableView.showsVerticalScrollIndicator = NO; 20 | [self.view addSubview:_tableView]; 21 | } 22 | return _tableView; 23 | } 24 | -(void)viewDidLoad 25 | { 26 | [super viewDidLoad]; 27 | self.view.backgroundColor = [UIColor whiteColor]; 28 | 29 | 30 | } 31 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 32 | { 33 | return [_dataArray count]; 34 | } 35 | - (UITableViewCell *)tableView:(UITableView *)tableView 36 | cellForRowAtIndexPath:(NSIndexPath *)indexPath { 37 | 38 | 39 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; 40 | if (cell == nil) { 41 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 42 | reuseIdentifier:@"Cell"] ; 43 | } 44 | 45 | // 一般我们就可以在这开始设置这个cell了,比如设置文字等: 46 | cell.textLabel.text = _dataArray[indexPath.row]; 47 | cell.textLabel.font = [UIFont systemFontOfSize:16]; 48 | cell.textLabel.textColor = [UIColor colorWithRed:54/255.0 green:54/255.0 blue:54/255.0 alpha:1]; 49 | return cell; 50 | } 51 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 52 | { 53 | NSString *string = _dataArray[indexPath.row]; 54 | if([_delegate respondsToSelector:@selector(didSelectedString:)]) 55 | { 56 | [_delegate didSelectedString:string]; 57 | } 58 | } 59 | -(void)scrollViewDidScroll:(UIScrollView *)scrollView 60 | { 61 | if([_delegate respondsToSelector:@selector(didScroll)]) 62 | { 63 | [_delegate didScroll]; 64 | } 65 | } 66 | @end 67 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/Model/CityModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // CityModel.h 3 | // MySelectCityDemo 4 | // 5 | // Created by 李阳 on 15/9/6. 6 | // Copyright (c) 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CityModel : NSObject 12 | @property (nonatomic,copy)NSString *name; 13 | @property (nonatomic,copy)NSString *pinYinName; 14 | @end 15 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/Model/CityModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // CityModel.m 3 | // MySelectCityDemo 4 | // 5 | // Created by 李阳 on 15/9/6. 6 | // Copyright (c) 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import "CityModel.h" 10 | 11 | @implementation CityModel 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/View/CityTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // CityTableViewCell.h 3 | // MySelectCityDemo 4 | // 5 | // Created by ZJ on 15/10/28. 6 | // Copyright © 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CityTableViewCell : UITableViewCell 12 | { 13 | NSArray * _cityArray; 14 | } 15 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cityArray:(NSArray*)array; 16 | @property (nonatomic,copy)void(^didSelectedBtn)(int tag); 17 | @end 18 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/View/CityTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // CityTableViewCell.m 3 | // MySelectCityDemo 4 | // 5 | // Created by ZJ on 15/10/28. 6 | // Copyright © 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import "CityTableViewCell.h" 10 | #define ScreenWidth [UIScreen mainScreen].bounds.size.width 11 | @implementation CityTableViewCell 12 | 13 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cityArray:(NSArray*)array 14 | { 15 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 16 | if (self) 17 | { 18 | _cityArray =array; 19 | self.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1]; 20 | for(int i=0;i 10 | 11 | @protocol CustomSearchViewDelegate 12 | 13 | -(void)searchBeginEditing; 14 | -(void)didSelectCancelBtn; 15 | -(void)searchString:(NSString *)string; 16 | @end 17 | 18 | 19 | @interface CustomSearchView : UIView 20 | @property (nonatomic,retain)UISearchBar *searchBar; 21 | @property (nonatomic,retain)UIButton *cancelBtn; 22 | @property (nonatomic,assign) id delegate; 23 | @end 24 | 25 | 26 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/View/CustomSearchView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomSearchView.m 3 | // MySelectCityDemo 4 | // 5 | // Created by 李阳 on 15/9/2. 6 | // Copyright (c) 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import "CustomSearchView.h" 10 | 11 | @implementation CustomSearchView 12 | -(id)initWithFrame:(CGRect)frame 13 | { 14 | self = [super initWithFrame:frame]; 15 | if(self) 16 | { 17 | self.backgroundColor = [UIColor colorWithRed:220/255.0 green:220/255.0 blue:220/255.0 alpha:1]; 18 | 19 | _searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(5, 7, frame.size.width-10, 30)]; 20 | _searchBar.placeholder = @"请输入城市名称/拼音"; 21 | _searchBar.delegate = self; 22 | 23 | _searchBar.barStyle = UIBarMetricsDefault; 24 | // searchBar.tintColor = [UIColor blueColor];// 搜索框的颜色,当设置此属性时,barStyle将失效 25 | [_searchBar setTranslucent:YES];// 设置是否透明 26 | [self addSubview:_searchBar]; 27 | _searchBar.backgroundImage = [self imageWithColor:[UIColor clearColor] size:_searchBar.bounds.size]; 28 | } 29 | return self; 30 | } 31 | // UISearchBar得到焦点并开始编辑时,执行该方法 32 | - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar 33 | { 34 | [searchBar setShowsCancelButton:YES animated:YES]; 35 | 36 | if(searchBar.text.length==0||[searchBar.text isEqualToString:@""]||[searchBar.text isKindOfClass:[NSNull class]]) 37 | { 38 | if([_delegate respondsToSelector:@selector(searchBeginEditing)]) 39 | { 40 | [_delegate searchBeginEditing]; 41 | } 42 | } 43 | else 44 | { 45 | if([_delegate respondsToSelector:@selector(searchString:)]) 46 | { 47 | [_delegate searchString:searchBar.text]; 48 | } 49 | } 50 | 51 | // return YES; 52 | } 53 | // 取消按钮被按下时,执行的方法 54 | - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar 55 | { 56 | searchBar.text = nil; 57 | [searchBar setShowsCancelButton:NO animated:YES]; 58 | [searchBar resignFirstResponder]; 59 | if([_delegate respondsToSelector:@selector(didSelectCancelBtn)]) 60 | { 61 | [_delegate didSelectCancelBtn]; 62 | } 63 | } 64 | // 键盘中,搜索按钮被按下,执行的方法 65 | - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar 66 | { 67 | // NSLog(@"searchBarSearchButtonClicked"); 68 | } 69 | // 当搜索内容变化时,执行该方法。很有用,可以实现时实搜索 70 | - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText 71 | { 72 | if([_delegate respondsToSelector:@selector(searchString:)]) 73 | { 74 | [_delegate searchString:searchText]; 75 | } 76 | } 77 | 78 | //取消searchbar背景色 79 | - (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size 80 | { 81 | CGRect rect = CGRectMake(0, 0, size.width, size.height); 82 | UIGraphicsBeginImageContext(rect.size); 83 | CGContextRef context = UIGraphicsGetCurrentContext(); 84 | 85 | CGContextSetFillColorWithColor(context, [color CGColor]); 86 | CGContextFillRect(context, rect); 87 | 88 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 89 | UIGraphicsEndImageContext(); 90 | 91 | return image; 92 | } 93 | @end 94 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/View/CustomTopView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CustomTopView.h 3 | // MySelectCityDemo 4 | // 5 | // Created by 李阳 on 15/9/1. 6 | // Copyright (c) 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol CustomTopViewDelegate 12 | 13 | -(void)didSelectBackButton; 14 | 15 | @end 16 | 17 | @interface CustomTopView : UIView 18 | @property (nonatomic,assign) id delegate; 19 | @end 20 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/View/CustomTopView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomTopView.m 3 | // MySelectCityDemo 4 | // 5 | // Created by 李阳 on 15/9/1. 6 | // Copyright (c) 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import "CustomTopView.h" 10 | 11 | @implementation CustomTopView 12 | -(id)initWithFrame:(CGRect)frame 13 | { 14 | self = [super initWithFrame:frame]; 15 | if(self) 16 | { 17 | self.backgroundColor = [UIColor colorWithRed:250/255.0 green:250/255.0 blue:250/255.0 alpha:1]; 18 | UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(10, 33, 22, 20)]; 19 | // [btn setTitle:@"返回" forState:UIControlStateNormal]; 20 | [btn setBackgroundImage:[UIImage imageNamed:@"cancelBtn" ] forState:0]; 21 | [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; 22 | [btn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside]; 23 | [self addSubview:btn]; 24 | 25 | UILabel *label = [[UILabel alloc] init]; 26 | label.backgroundColor = [UIColor clearColor]; 27 | label.textAlignment = NSTextAlignmentCenter; 28 | label.center = CGPointMake(frame.size.width/2, (frame.size.height/2)+10); 29 | label.bounds = CGRectMake(0, 0, 100, 30); 30 | label.text = @"选择城市"; 31 | label.font = [UIFont systemFontOfSize:19]; 32 | label.textColor = [UIColor colorWithRed:54/255.0 green:54/255.0 blue:54/255.0 alpha:1]; 33 | [self addSubview:label]; 34 | 35 | UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, frame.size.height-1, frame.size.width, 1)]; 36 | lineView.backgroundColor = [UIColor colorWithRed:200/255.0 green:200/255.0 blue:200/255.0 alpha:1]; 37 | [self addSubview:lineView]; 38 | } 39 | return self; 40 | } 41 | -(void)click 42 | { 43 | if([_delegate respondsToSelector:@selector(didSelectBackButton)]) 44 | { 45 | [_delegate didSelectBackButton]; 46 | } 47 | } 48 | @end 49 | -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/cancelBtn@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderZhou10496/SelectCityDemo/911eb9bd2eb44974b7c130de3b37ce109a5e9d30/SelectCityDemo/selectCity/cancelBtn@2x.png -------------------------------------------------------------------------------- /SelectCityDemo/selectCity/citydict.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A 6 | 7 | 阿坝藏族羌族自治州 8 | 阿克苏地区 9 | 阿拉尔 10 | 阿拉善盟 11 | 阿勒泰地区 12 | 阿里地区 13 | 安康 14 | 安庆 15 | 安顺 16 | 安阳 17 | 鞍山 18 | 澳门特别行政区 19 | 20 | B 21 | 22 | 巴彦淖尔 23 | 巴音郭楞蒙古自治州 24 | 巴中 25 | 白城 26 | 白沙黎族自治县 27 | 白山 28 | 白银 29 | 百色 30 | 蚌埠 31 | 包头 32 | 宝鸡 33 | 保定 34 | 保山 35 | 保亭黎族苗族自治县 36 | 北海 37 | 北京 38 | 本溪 39 | 毕节地区 40 | 滨州 41 | 亳州 42 | 博尔塔拉蒙古自治州 43 | 44 | C 45 | 46 | 沧州 47 | 昌都地区 48 | 昌吉回族自治州 49 | 昌江黎族自治县 50 | 长春 51 | 长沙 52 | 长治 53 | 常德 54 | 常州 55 | 巢湖 56 | 朝阳 57 | 潮州 58 | 郴州 59 | 成都 60 | 承德 61 | 澄迈县 62 | 池州 63 | 赤峰 64 | 崇左 65 | 滁州 66 | 楚雄彝族自治州 67 | 68 | D 69 | 70 | 达州 71 | 大理白族自治州 72 | 大连 73 | 大庆 74 | 大同 75 | 大兴安岭地区 76 | 丹东 77 | 儋州 78 | 德宏傣族景颇族自治州 79 | 德阳 80 | 德州 81 | 迪庆藏族自治州 82 | 定安县 83 | 定西 84 | 东方 85 | 东莞 86 | 东营 87 | 88 | E 89 | 90 | 鄂尔多斯 91 | 鄂州 92 | 恩施土家族苗族自治州 93 | 94 | F 95 | 96 | 防城港 97 | 佛山 98 | 福州 99 | 抚顺 100 | 抚州 101 | 阜新 102 | 阜阳 103 | 104 | G 105 | 106 | 甘南藏族自治州 107 | 甘孜藏族自治州 108 | 赣州 109 | 高雄 110 | 高雄县 111 | 固原 112 | 广安 113 | 广元 114 | 广州 115 | 贵港 116 | 贵阳 117 | 桂林 118 | 果洛藏族自治州 119 | 120 | H 121 | 122 | 哈尔滨 123 | 哈密地区 124 | 海外 125 | 海北藏族自治州 126 | 海东地区 127 | 海口 128 | 海南藏族自治州 129 | 海西蒙古族藏族自治州 130 | 邯郸 131 | 汉中 132 | 杭州 133 | 合肥 134 | 和田地区 135 | 河池 136 | 河源 137 | 菏泽 138 | 贺州 139 | 鹤壁 140 | 鹤岗 141 | 黑河 142 | 衡水 143 | 衡阳 144 | 红河哈尼族彝族自治州 145 | 呼和浩特 146 | 呼伦贝尔 147 | 湖州 148 | 葫芦岛 149 | 花莲县 150 | 怀化 151 | 淮安 152 | 淮北 153 | 淮南 154 | 黄冈 155 | 黄南藏族自治州 156 | 黄山 157 | 黄石 158 | 惠州 159 | 160 | J 161 | 162 | 鸡西 163 | 基隆 164 | 吉安 165 | 吉林 166 | 济南 167 | 济宁 168 | 济源 169 | 佳木斯 170 | 嘉兴 171 | 嘉义 172 | 嘉义县 173 | 嘉峪关 174 | 江门 175 | 焦作 176 | 揭阳 177 | 金昌 178 | 金华 179 | 锦州 180 | 晋城 181 | 晋中 182 | 荆门 183 | 荆州 184 | 景德镇 185 | 九江 186 | 酒泉 187 | 188 | K 189 | 190 | 喀什地区 191 | 开封 192 | 克拉玛依 193 | 克孜勒苏柯尔克孜自治州 194 | 昆明 195 | 196 | L 197 | 198 | 拉萨 199 | 来宾 200 | 莱芜 201 | 兰州 202 | 廊坊 203 | 乐东黎族自治县 204 | 乐山 205 | 丽江 206 | 丽水 207 | 连云港 208 | 凉山彝族自治州 209 | 辽阳 210 | 辽源 211 | 聊城 212 | 林芝地区 213 | 临沧 214 | 临汾 215 | 临高县 216 | 临夏回族自治州 217 | 临沂 218 | 陵水黎族自治县 219 | 柳州 220 | 六安 221 | 六盘水 222 | 龙岩 223 | 陇南 224 | 娄底 225 | 泸州 226 | 吕梁 227 | 洛阳 228 | 漯河 229 | 230 | M 231 | 232 | 马鞍山 233 | 茂名 234 | 眉山 235 | 梅州 236 | 绵阳 237 | 苗栗县 238 | 牡丹江 239 | 240 | N 241 | 242 | 内江 243 | 那曲地区 244 | 南昌 245 | 南充 246 | 南京 247 | 南宁 248 | 南平 249 | 南沙群岛 250 | 南通 251 | 南投县 252 | 南阳 253 | 宁波 254 | 宁德 255 | 怒江傈僳族自治州 256 | 257 | P 258 | 259 | 攀枝花 260 | 盘锦 261 | 澎湖县 262 | 平顶山 263 | 平凉 264 | 屏东县 265 | 萍乡 266 | 莆田 267 | 濮阳 268 | 269 | Q 270 | 271 | 七台河 272 | 齐齐哈尔 273 | 其他 274 | 潜江 275 | 黔东南苗族侗族自治州 276 | 黔南布依族苗族自治州 277 | 黔西南布依族苗族自治州 278 | 钦州 279 | 秦皇岛 280 | 青岛 281 | 清远 282 | 庆阳 283 | 琼海 284 | 琼中黎族苗族自治县 285 | 曲靖 286 | 衢州 287 | 泉州 288 | 289 | R 290 | 291 | 日喀则地区 292 | 日照 293 | 294 | S 295 | 296 | 三门峡 297 | 三明 298 | 三亚 299 | 山南地区 300 | 汕头 301 | 汕尾 302 | 商洛 303 | 商丘 304 | 上海 305 | 上饶 306 | 韶关 307 | 邵阳 308 | 绍兴 309 | 深圳 310 | 神农架林区 311 | 沈阳 312 | 十堰 313 | 石河子 314 | 石家庄 315 | 石嘴山 316 | 双鸭山 317 | 朔州 318 | 思茅 319 | 四平 320 | 松原 321 | 苏州 322 | 宿迁 323 | 宿州 324 | 绥化 325 | 随州 326 | 遂宁 327 | 328 | T 329 | 330 | 塔城地区 331 | 台北 332 | 台北县 333 | 台东县 334 | 台南 335 | 台南县 336 | 台中 337 | 台中县 338 | 台州 339 | 太原 340 | 泰安 341 | 泰州 342 | 唐山 343 | 桃园县 344 | 天津 345 | 天门 346 | 天水 347 | 铁岭 348 | 通化 349 | 通辽 350 | 铜川 351 | 铜陵 352 | 铜仁地区 353 | 图木舒克 354 | 吐鲁番地区 355 | 屯昌县 356 | 357 | W 358 | 359 | 无锡 360 | 万宁 361 | 威海 362 | 潍坊 363 | 渭南 364 | 温州 365 | 文昌 366 | 文山壮族苗族自治州 367 | 乌海 368 | 乌兰察布 369 | 乌鲁木齐 370 | 吴忠 371 | 芜湖 372 | 梧州 373 | 五家渠 374 | 五指山 375 | 武汉 376 | 武威 377 | 378 | X 379 | 380 | 西安 381 | 西宁 382 | 西沙群岛 383 | 西双版纳傣族自治州 384 | 锡林郭勒盟 385 | 厦门 386 | 仙桃 387 | 咸宁 388 | 咸阳 389 | 香港特别行政区 390 | 湘潭 391 | 湘西土家族苗族自治州 392 | 襄樊 393 | 孝感 394 | 忻州 395 | 新乡 396 | 新余 397 | 新竹 398 | 新竹县 399 | 信阳 400 | 兴安盟 401 | 邢台 402 | 徐州 403 | 许昌 404 | 宣城 405 | 406 | Y 407 | 408 | 雅安 409 | 烟台 410 | 延安 411 | 延边朝鲜族自治州 412 | 盐城 413 | 扬州 414 | 阳江 415 | 阳泉 416 | 伊春 417 | 伊犁哈萨克自治州 418 | 宜宾 419 | 宜昌 420 | 宜春 421 | 宜兰县 422 | 益阳 423 | 银川 424 | 鹰潭 425 | 营口 426 | 永州 427 | 榆林 428 | 玉林 429 | 玉树藏族自治州 430 | 玉溪 431 | 岳阳 432 | 云浮 433 | 云林县 434 | 运城 435 | 436 | Z 437 | 438 | 枣庄 439 | 湛江 440 | 张家界 441 | 张家口 442 | 张掖 443 | 彰化县 444 | 漳州 445 | 昭通 446 | 肇庆 447 | 镇江 448 | 郑州 449 | 中沙群岛的岛礁及其海域 450 | 中山 451 | 中卫 452 | 重庆 453 | 舟山 454 | 周口 455 | 株洲 456 | 珠海 457 | 驻马店 458 | 资阳 459 | 淄博 460 | 自贡 461 | 遵义 462 | 463 | 464 | -------------------------------------------------------------------------------- /SelectCityDemoTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SelectCityDemoTests/SelectCityDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SelectCityDemoTests.m 3 | // SelectCityDemoTests 4 | // 5 | // Created by ZJ on 15/11/4. 6 | // Copyright © 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SelectCityDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SelectCityDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /SelectCityDemoUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SelectCityDemoUITests/SelectCityDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SelectCityDemoUITests.m 3 | // SelectCityDemoUITests 4 | // 5 | // Created by ZJ on 15/11/4. 6 | // Copyright © 2015年 WXDL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SelectCityDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SelectCityDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /selectCity.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderZhou10496/SelectCityDemo/911eb9bd2eb44974b7c130de3b37ce109a5e9d30/selectCity.gif --------------------------------------------------------------------------------