├── README.md ├── SearchBarDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── Leo.xcuserdatad │ └── xcschemes │ ├── SearchBarDemo.xcscheme │ └── xcschememanagement.plist ├── SearchBarDemo ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── ViewController.h ├── ViewController.m ├── main.m └── zh-Hans.lproj │ ├── LaunchScreen.strings │ └── Main.strings └── SearchBarDemoTests ├── Info.plist └── SearchBarDemoTests.m /README.md: -------------------------------------------------------------------------------- 1 | # SearchBarDemo 2 | 3 | How to use UISearchBar?! 4 | -------------------------------------------------------------------------------- /SearchBarDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B3A26EF51B85A61200612F0F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B3A26EF41B85A61200612F0F /* main.m */; }; 11 | B3A26EF81B85A61200612F0F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B3A26EF71B85A61200612F0F /* AppDelegate.m */; }; 12 | B3A26EFB1B85A61200612F0F /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B3A26EFA1B85A61200612F0F /* ViewController.m */; }; 13 | B3A26EFE1B85A61200612F0F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B3A26EFC1B85A61200612F0F /* Main.storyboard */; }; 14 | B3A26F001B85A61200612F0F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B3A26EFF1B85A61200612F0F /* Images.xcassets */; }; 15 | B3A26F031B85A61200612F0F /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = B3A26F011B85A61200612F0F /* LaunchScreen.xib */; }; 16 | B3A26F0F1B85A61300612F0F /* SearchBarDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B3A26F0E1B85A61300612F0F /* SearchBarDemoTests.m */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | B3A26F091B85A61300612F0F /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = B3A26EE71B85A61200612F0F /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = B3A26EEE1B85A61200612F0F; 25 | remoteInfo = SearchBarDemo; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | B3A26EEF1B85A61200612F0F /* SearchBarDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SearchBarDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | B3A26EF31B85A61200612F0F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | B3A26EF41B85A61200612F0F /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 33 | B3A26EF61B85A61200612F0F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 34 | B3A26EF71B85A61200612F0F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 35 | B3A26EF91B85A61200612F0F /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 36 | B3A26EFA1B85A61200612F0F /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 37 | B3A26EFD1B85A61200612F0F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 38 | B3A26EFF1B85A61200612F0F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 39 | B3A26F021B85A61200612F0F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 40 | B3A26F081B85A61300612F0F /* SearchBarDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SearchBarDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | B3A26F0D1B85A61300612F0F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | B3A26F0E1B85A61300612F0F /* SearchBarDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SearchBarDemoTests.m; sourceTree = ""; }; 43 | B3A26F181B85B0BF00612F0F /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; 44 | B3A26F191B85B0BF00612F0F /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | B3A26EEC1B85A61200612F0F /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | B3A26F051B85A61300612F0F /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | B3A26EE61B85A61200612F0F = { 66 | isa = PBXGroup; 67 | children = ( 68 | B3A26EF11B85A61200612F0F /* SearchBarDemo */, 69 | B3A26F0B1B85A61300612F0F /* SearchBarDemoTests */, 70 | B3A26EF01B85A61200612F0F /* Products */, 71 | ); 72 | sourceTree = ""; 73 | }; 74 | B3A26EF01B85A61200612F0F /* Products */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | B3A26EEF1B85A61200612F0F /* SearchBarDemo.app */, 78 | B3A26F081B85A61300612F0F /* SearchBarDemoTests.xctest */, 79 | ); 80 | name = Products; 81 | sourceTree = ""; 82 | }; 83 | B3A26EF11B85A61200612F0F /* SearchBarDemo */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | B3A26EF61B85A61200612F0F /* AppDelegate.h */, 87 | B3A26EF71B85A61200612F0F /* AppDelegate.m */, 88 | B3A26EF91B85A61200612F0F /* ViewController.h */, 89 | B3A26EFA1B85A61200612F0F /* ViewController.m */, 90 | B3A26EFC1B85A61200612F0F /* Main.storyboard */, 91 | B3A26EF21B85A61200612F0F /* Supporting Files */, 92 | ); 93 | path = SearchBarDemo; 94 | sourceTree = ""; 95 | }; 96 | B3A26EF21B85A61200612F0F /* Supporting Files */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | B3A26EFF1B85A61200612F0F /* Images.xcassets */, 100 | B3A26F011B85A61200612F0F /* LaunchScreen.xib */, 101 | B3A26EF31B85A61200612F0F /* Info.plist */, 102 | B3A26EF41B85A61200612F0F /* main.m */, 103 | ); 104 | name = "Supporting Files"; 105 | sourceTree = ""; 106 | }; 107 | B3A26F0B1B85A61300612F0F /* SearchBarDemoTests */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | B3A26F0E1B85A61300612F0F /* SearchBarDemoTests.m */, 111 | B3A26F0C1B85A61300612F0F /* Supporting Files */, 112 | ); 113 | path = SearchBarDemoTests; 114 | sourceTree = ""; 115 | }; 116 | B3A26F0C1B85A61300612F0F /* Supporting Files */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | B3A26F0D1B85A61300612F0F /* Info.plist */, 120 | ); 121 | name = "Supporting Files"; 122 | sourceTree = ""; 123 | }; 124 | /* End PBXGroup section */ 125 | 126 | /* Begin PBXNativeTarget section */ 127 | B3A26EEE1B85A61200612F0F /* SearchBarDemo */ = { 128 | isa = PBXNativeTarget; 129 | buildConfigurationList = B3A26F121B85A61300612F0F /* Build configuration list for PBXNativeTarget "SearchBarDemo" */; 130 | buildPhases = ( 131 | B3A26EEB1B85A61200612F0F /* Sources */, 132 | B3A26EEC1B85A61200612F0F /* Frameworks */, 133 | B3A26EED1B85A61200612F0F /* Resources */, 134 | ); 135 | buildRules = ( 136 | ); 137 | dependencies = ( 138 | ); 139 | name = SearchBarDemo; 140 | productName = SearchBarDemo; 141 | productReference = B3A26EEF1B85A61200612F0F /* SearchBarDemo.app */; 142 | productType = "com.apple.product-type.application"; 143 | }; 144 | B3A26F071B85A61300612F0F /* SearchBarDemoTests */ = { 145 | isa = PBXNativeTarget; 146 | buildConfigurationList = B3A26F151B85A61300612F0F /* Build configuration list for PBXNativeTarget "SearchBarDemoTests" */; 147 | buildPhases = ( 148 | B3A26F041B85A61300612F0F /* Sources */, 149 | B3A26F051B85A61300612F0F /* Frameworks */, 150 | B3A26F061B85A61300612F0F /* Resources */, 151 | ); 152 | buildRules = ( 153 | ); 154 | dependencies = ( 155 | B3A26F0A1B85A61300612F0F /* PBXTargetDependency */, 156 | ); 157 | name = SearchBarDemoTests; 158 | productName = SearchBarDemoTests; 159 | productReference = B3A26F081B85A61300612F0F /* SearchBarDemoTests.xctest */; 160 | productType = "com.apple.product-type.bundle.unit-test"; 161 | }; 162 | /* End PBXNativeTarget section */ 163 | 164 | /* Begin PBXProject section */ 165 | B3A26EE71B85A61200612F0F /* Project object */ = { 166 | isa = PBXProject; 167 | attributes = { 168 | LastUpgradeCheck = 0640; 169 | ORGANIZATIONNAME = Leo; 170 | TargetAttributes = { 171 | B3A26EEE1B85A61200612F0F = { 172 | CreatedOnToolsVersion = 6.4; 173 | }; 174 | B3A26F071B85A61300612F0F = { 175 | CreatedOnToolsVersion = 6.4; 176 | TestTargetID = B3A26EEE1B85A61200612F0F; 177 | }; 178 | }; 179 | }; 180 | buildConfigurationList = B3A26EEA1B85A61200612F0F /* Build configuration list for PBXProject "SearchBarDemo" */; 181 | compatibilityVersion = "Xcode 3.2"; 182 | developmentRegion = English; 183 | hasScannedForEncodings = 0; 184 | knownRegions = ( 185 | en, 186 | Base, 187 | ); 188 | mainGroup = B3A26EE61B85A61200612F0F; 189 | productRefGroup = B3A26EF01B85A61200612F0F /* Products */; 190 | projectDirPath = ""; 191 | projectRoot = ""; 192 | targets = ( 193 | B3A26EEE1B85A61200612F0F /* SearchBarDemo */, 194 | B3A26F071B85A61300612F0F /* SearchBarDemoTests */, 195 | ); 196 | }; 197 | /* End PBXProject section */ 198 | 199 | /* Begin PBXResourcesBuildPhase section */ 200 | B3A26EED1B85A61200612F0F /* Resources */ = { 201 | isa = PBXResourcesBuildPhase; 202 | buildActionMask = 2147483647; 203 | files = ( 204 | B3A26EFE1B85A61200612F0F /* Main.storyboard in Resources */, 205 | B3A26F031B85A61200612F0F /* LaunchScreen.xib in Resources */, 206 | B3A26F001B85A61200612F0F /* Images.xcassets in Resources */, 207 | ); 208 | runOnlyForDeploymentPostprocessing = 0; 209 | }; 210 | B3A26F061B85A61300612F0F /* Resources */ = { 211 | isa = PBXResourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | ); 215 | runOnlyForDeploymentPostprocessing = 0; 216 | }; 217 | /* End PBXResourcesBuildPhase section */ 218 | 219 | /* Begin PBXSourcesBuildPhase section */ 220 | B3A26EEB1B85A61200612F0F /* Sources */ = { 221 | isa = PBXSourcesBuildPhase; 222 | buildActionMask = 2147483647; 223 | files = ( 224 | B3A26EFB1B85A61200612F0F /* ViewController.m in Sources */, 225 | B3A26EF81B85A61200612F0F /* AppDelegate.m in Sources */, 226 | B3A26EF51B85A61200612F0F /* main.m in Sources */, 227 | ); 228 | runOnlyForDeploymentPostprocessing = 0; 229 | }; 230 | B3A26F041B85A61300612F0F /* Sources */ = { 231 | isa = PBXSourcesBuildPhase; 232 | buildActionMask = 2147483647; 233 | files = ( 234 | B3A26F0F1B85A61300612F0F /* SearchBarDemoTests.m in Sources */, 235 | ); 236 | runOnlyForDeploymentPostprocessing = 0; 237 | }; 238 | /* End PBXSourcesBuildPhase section */ 239 | 240 | /* Begin PBXTargetDependency section */ 241 | B3A26F0A1B85A61300612F0F /* PBXTargetDependency */ = { 242 | isa = PBXTargetDependency; 243 | target = B3A26EEE1B85A61200612F0F /* SearchBarDemo */; 244 | targetProxy = B3A26F091B85A61300612F0F /* PBXContainerItemProxy */; 245 | }; 246 | /* End PBXTargetDependency section */ 247 | 248 | /* Begin PBXVariantGroup section */ 249 | B3A26EFC1B85A61200612F0F /* Main.storyboard */ = { 250 | isa = PBXVariantGroup; 251 | children = ( 252 | B3A26EFD1B85A61200612F0F /* Base */, 253 | B3A26F181B85B0BF00612F0F /* zh-Hans */, 254 | ); 255 | name = Main.storyboard; 256 | sourceTree = ""; 257 | }; 258 | B3A26F011B85A61200612F0F /* LaunchScreen.xib */ = { 259 | isa = PBXVariantGroup; 260 | children = ( 261 | B3A26F021B85A61200612F0F /* Base */, 262 | B3A26F191B85B0BF00612F0F /* zh-Hans */, 263 | ); 264 | name = LaunchScreen.xib; 265 | sourceTree = ""; 266 | }; 267 | /* End PBXVariantGroup section */ 268 | 269 | /* Begin XCBuildConfiguration section */ 270 | B3A26F101B85A61300612F0F /* Debug */ = { 271 | isa = XCBuildConfiguration; 272 | buildSettings = { 273 | ALWAYS_SEARCH_USER_PATHS = NO; 274 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 275 | CLANG_CXX_LIBRARY = "libc++"; 276 | CLANG_ENABLE_MODULES = YES; 277 | CLANG_ENABLE_OBJC_ARC = YES; 278 | CLANG_WARN_BOOL_CONVERSION = YES; 279 | CLANG_WARN_CONSTANT_CONVERSION = YES; 280 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 281 | CLANG_WARN_EMPTY_BODY = YES; 282 | CLANG_WARN_ENUM_CONVERSION = YES; 283 | CLANG_WARN_INT_CONVERSION = YES; 284 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 285 | CLANG_WARN_UNREACHABLE_CODE = YES; 286 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 287 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 288 | COPY_PHASE_STRIP = NO; 289 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 290 | ENABLE_STRICT_OBJC_MSGSEND = YES; 291 | GCC_C_LANGUAGE_STANDARD = gnu99; 292 | GCC_DYNAMIC_NO_PIC = NO; 293 | GCC_NO_COMMON_BLOCKS = YES; 294 | GCC_OPTIMIZATION_LEVEL = 0; 295 | GCC_PREPROCESSOR_DEFINITIONS = ( 296 | "DEBUG=1", 297 | "$(inherited)", 298 | ); 299 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 300 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 301 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 302 | GCC_WARN_UNDECLARED_SELECTOR = YES; 303 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 304 | GCC_WARN_UNUSED_FUNCTION = YES; 305 | GCC_WARN_UNUSED_VARIABLE = YES; 306 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 307 | MTL_ENABLE_DEBUG_INFO = YES; 308 | ONLY_ACTIVE_ARCH = YES; 309 | SDKROOT = iphoneos; 310 | TARGETED_DEVICE_FAMILY = "1,2"; 311 | }; 312 | name = Debug; 313 | }; 314 | B3A26F111B85A61300612F0F /* Release */ = { 315 | isa = XCBuildConfiguration; 316 | buildSettings = { 317 | ALWAYS_SEARCH_USER_PATHS = NO; 318 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 319 | CLANG_CXX_LIBRARY = "libc++"; 320 | CLANG_ENABLE_MODULES = YES; 321 | CLANG_ENABLE_OBJC_ARC = YES; 322 | CLANG_WARN_BOOL_CONVERSION = YES; 323 | CLANG_WARN_CONSTANT_CONVERSION = YES; 324 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 325 | CLANG_WARN_EMPTY_BODY = YES; 326 | CLANG_WARN_ENUM_CONVERSION = YES; 327 | CLANG_WARN_INT_CONVERSION = YES; 328 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 329 | CLANG_WARN_UNREACHABLE_CODE = YES; 330 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 331 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 332 | COPY_PHASE_STRIP = NO; 333 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 334 | ENABLE_NS_ASSERTIONS = NO; 335 | ENABLE_STRICT_OBJC_MSGSEND = YES; 336 | GCC_C_LANGUAGE_STANDARD = gnu99; 337 | GCC_NO_COMMON_BLOCKS = YES; 338 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 339 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 340 | GCC_WARN_UNDECLARED_SELECTOR = YES; 341 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 342 | GCC_WARN_UNUSED_FUNCTION = YES; 343 | GCC_WARN_UNUSED_VARIABLE = YES; 344 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 345 | MTL_ENABLE_DEBUG_INFO = NO; 346 | SDKROOT = iphoneos; 347 | TARGETED_DEVICE_FAMILY = "1,2"; 348 | VALIDATE_PRODUCT = YES; 349 | }; 350 | name = Release; 351 | }; 352 | B3A26F131B85A61300612F0F /* Debug */ = { 353 | isa = XCBuildConfiguration; 354 | buildSettings = { 355 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 356 | INFOPLIST_FILE = SearchBarDemo/Info.plist; 357 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 358 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 359 | PRODUCT_NAME = "$(TARGET_NAME)"; 360 | }; 361 | name = Debug; 362 | }; 363 | B3A26F141B85A61300612F0F /* Release */ = { 364 | isa = XCBuildConfiguration; 365 | buildSettings = { 366 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 367 | INFOPLIST_FILE = SearchBarDemo/Info.plist; 368 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 369 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 370 | PRODUCT_NAME = "$(TARGET_NAME)"; 371 | }; 372 | name = Release; 373 | }; 374 | B3A26F161B85A61300612F0F /* Debug */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | BUNDLE_LOADER = "$(TEST_HOST)"; 378 | FRAMEWORK_SEARCH_PATHS = ( 379 | "$(SDKROOT)/Developer/Library/Frameworks", 380 | "$(inherited)", 381 | ); 382 | GCC_PREPROCESSOR_DEFINITIONS = ( 383 | "DEBUG=1", 384 | "$(inherited)", 385 | ); 386 | INFOPLIST_FILE = SearchBarDemoTests/Info.plist; 387 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 388 | PRODUCT_NAME = "$(TARGET_NAME)"; 389 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SearchBarDemo.app/SearchBarDemo"; 390 | }; 391 | name = Debug; 392 | }; 393 | B3A26F171B85A61300612F0F /* Release */ = { 394 | isa = XCBuildConfiguration; 395 | buildSettings = { 396 | BUNDLE_LOADER = "$(TEST_HOST)"; 397 | FRAMEWORK_SEARCH_PATHS = ( 398 | "$(SDKROOT)/Developer/Library/Frameworks", 399 | "$(inherited)", 400 | ); 401 | INFOPLIST_FILE = SearchBarDemoTests/Info.plist; 402 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 403 | PRODUCT_NAME = "$(TARGET_NAME)"; 404 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SearchBarDemo.app/SearchBarDemo"; 405 | }; 406 | name = Release; 407 | }; 408 | /* End XCBuildConfiguration section */ 409 | 410 | /* Begin XCConfigurationList section */ 411 | B3A26EEA1B85A61200612F0F /* Build configuration list for PBXProject "SearchBarDemo" */ = { 412 | isa = XCConfigurationList; 413 | buildConfigurations = ( 414 | B3A26F101B85A61300612F0F /* Debug */, 415 | B3A26F111B85A61300612F0F /* Release */, 416 | ); 417 | defaultConfigurationIsVisible = 0; 418 | defaultConfigurationName = Release; 419 | }; 420 | B3A26F121B85A61300612F0F /* Build configuration list for PBXNativeTarget "SearchBarDemo" */ = { 421 | isa = XCConfigurationList; 422 | buildConfigurations = ( 423 | B3A26F131B85A61300612F0F /* Debug */, 424 | B3A26F141B85A61300612F0F /* Release */, 425 | ); 426 | defaultConfigurationIsVisible = 0; 427 | }; 428 | B3A26F151B85A61300612F0F /* Build configuration list for PBXNativeTarget "SearchBarDemoTests" */ = { 429 | isa = XCConfigurationList; 430 | buildConfigurations = ( 431 | B3A26F161B85A61300612F0F /* Debug */, 432 | B3A26F171B85A61300612F0F /* Release */, 433 | ); 434 | defaultConfigurationIsVisible = 0; 435 | }; 436 | /* End XCConfigurationList section */ 437 | }; 438 | rootObject = B3A26EE71B85A61200612F0F /* Project object */; 439 | } 440 | -------------------------------------------------------------------------------- /SearchBarDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SearchBarDemo.xcodeproj/xcuserdata/Leo.xcuserdatad/xcschemes/SearchBarDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /SearchBarDemo.xcodeproj/xcuserdata/Leo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SearchBarDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | B3A26EEE1B85A61200612F0F 16 | 17 | primary 18 | 19 | 20 | B3A26F071B85A61300612F0F 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SearchBarDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SearchBarDemo 4 | // 5 | // Created by 刘超 on 15/8/20. 6 | // Copyright (c) 2015年 Leo. 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 | -------------------------------------------------------------------------------- /SearchBarDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SearchBarDemo 4 | // 5 | // Created by 刘超 on 15/8/20. 6 | // Copyright (c) 2015年 Leo. 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 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /SearchBarDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SearchBarDemo/Base.lproj/Main.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 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 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 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /SearchBarDemo/Images.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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /SearchBarDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.leodong.$(PRODUCT_NAME:rfc1034identifier) 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 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /SearchBarDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SearchBarDemo 4 | // 5 | // Created by 刘超 on 15/8/20. 6 | // Copyright (c) 2015年 Leo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SearchBarDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SearchBarDemo 4 | // 5 | // Created by 刘超 on 15/8/20. 6 | // Copyright (c) 2015年 Leo. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @property (strong, nonatomic) IBOutlet UISearchDisplayController *searchDC; 14 | @property (weak, nonatomic) IBOutlet UISearchBar *searchBar; 15 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 16 | 17 | @property (nonatomic, strong) NSArray *items; 18 | @property (nonatomic, strong) NSArray *searchResults; 19 | 20 | @end 21 | 22 | @implementation ViewController 23 | 24 | - (void)viewDidLoad { 25 | 26 | [super viewDidLoad]; 27 | 28 | self.title = @"LOL科普:地名大全"; 29 | 30 | self.items = @[@"国服第一臭豆腐 No.1 Stinky Tofu CN.", 31 | @"瓦洛兰 Valoran", 32 | @"德玛西亚 Demacia", 33 | @"诺克萨斯 Noxus", 34 | @"艾欧尼亚 Ionia", 35 | @"皮尔特沃夫 Piltover", 36 | @"弗雷尔卓德 Freijord", 37 | @"班德尔城 Bandle City", 38 | @"战争学院 The Institute of War", 39 | @"祖安 Zaun", 40 | @"卡拉曼达 Kalamanda", 41 | @"蓝焰岛 Blue Flame Island", 42 | @"哀嚎沼泽 Howling Marsh", 43 | @"艾卡西亚 Icathia", 44 | @"铁脊山脉 Ironspike Mountains", 45 | @"库莽古丛林 Kumungu", 46 | @"洛克法 Lokfar", 47 | @"摩根小道 Morgon Pass", 48 | @"塔尔贡山脉 Mountain Targon", 49 | @"瘟疫丛林 Plague Jungles", 50 | @"盘蛇河 Serpentine River", 51 | @"恕瑞玛沙漠 Shurima Desert", 52 | @"厄尔提斯坦 Urtistan", 53 | @"巫毒之地 Voodoo Lands", 54 | @"水晶之痕 Crystal Scar", 55 | @"咆哮深渊 Howling Abyss", 56 | @"熔岩洞窟 Magma Chambers", 57 | @"试炼之地 Proving Grounds", 58 | @"召唤师峡谷 Summoner's Rift", 59 | @"扭曲丛林 Twisted Treeline"]; 60 | 61 | // self.searchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"BOY",@"GIRL",@"ALL",nil]; 62 | } 63 | 64 | /** 65 | * 通过搜索条件过滤得到搜索结果 66 | * 67 | * @param searchText 关键词 68 | * @param scope 范围 69 | */ 70 | - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope { 71 | 72 | NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", searchText]; 73 | 74 | self.searchResults = [self.items filteredArrayUsingPredicate:resultPredicate]; 75 | } 76 | 77 | #pragma mark - UITabelView 代理 78 | 79 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 80 | 81 | return (tableView == self.tableView) ? self.items.count : self.searchResults.count; 82 | } 83 | 84 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 85 | 86 | static NSString *ID = @"cell"; 87 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; 88 | if (!cell) { 89 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID]; 90 | } 91 | 92 | cell.textLabel.text = (tableView == self.tableView) ? self.items[indexPath.row] : self.searchResults[indexPath.row]; 93 | 94 | return cell; 95 | } 96 | 97 | #pragma mark - UISearchDisplayController 代理 98 | 99 | - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { 100 | 101 | [self filterContentForSearchText:searchString scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]]; 102 | 103 | return YES; 104 | } 105 | 106 | - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption { 107 | 108 | [self filterContentForSearchText:[self.searchDisplayController.searchBar text] scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:searchOption]]; 109 | 110 | return YES; 111 | } 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /SearchBarDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SearchBarDemo 4 | // 5 | // Created by 刘超 on 15/8/20. 6 | // Copyright (c) 2015年 Leo. 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 | -------------------------------------------------------------------------------- /SearchBarDemo/zh-Hans.lproj/LaunchScreen.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "UILabel"; text = " Copyright (c) 2015年 Leo. All rights reserved."; ObjectID = "8ie-xW-0ye"; */ 3 | "8ie-xW-0ye.text" = " Copyright (c) 2015年 Leo. All rights reserved."; 4 | 5 | /* Class = "UILabel"; text = "SearchBarDemo"; ObjectID = "kId-c2-rCX"; */ 6 | "kId-c2-rCX.text" = "SearchBarDemo"; 7 | -------------------------------------------------------------------------------- /SearchBarDemo/zh-Hans.lproj/Main.strings: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /SearchBarDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.leodong.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /SearchBarDemoTests/SearchBarDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SearchBarDemoTests.m 3 | // SearchBarDemoTests 4 | // 5 | // Created by 刘超 on 15/8/20. 6 | // Copyright (c) 2015年 Leo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface SearchBarDemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation SearchBarDemoTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------