Skip to content

Commit c73b9fb

Browse files
committed
SearchController with scope bar hidden (the default behavior)
1 parent b078b5e commit c73b9fb

File tree

6 files changed

+20
-148
lines changed

6 files changed

+20
-148
lines changed

SearchController.xcodeproj/project.pbxproj

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@
88

99
/* Begin PBXBuildFile section */
1010
B505EA532453E00D00B19A1D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B505EA522453E00D00B19A1D /* AppDelegate.swift */; };
11-
B505EA552453E00D00B19A1D /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B505EA542453E00D00B19A1D /* SceneDelegate.swift */; };
1211
B505EA572453E00D00B19A1D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B505EA562453E00D00B19A1D /* ViewController.swift */; };
13-
B505EA5A2453E00D00B19A1D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B505EA582453E00D00B19A1D /* Main.storyboard */; };
1412
B505EA5C2453E00E00B19A1D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B505EA5B2453E00E00B19A1D /* Assets.xcassets */; };
1513
B505EA5F2453E00E00B19A1D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B505EA5D2453E00E00B19A1D /* LaunchScreen.storyboard */; };
1614
/* End PBXBuildFile section */
1715

1816
/* Begin PBXFileReference section */
1917
B505EA4F2453E00D00B19A1D /* SearchController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SearchController.app; sourceTree = BUILT_PRODUCTS_DIR; };
2018
B505EA522453E00D00B19A1D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
21-
B505EA542453E00D00B19A1D /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
2219
B505EA562453E00D00B19A1D /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
23-
B505EA592453E00D00B19A1D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
2420
B505EA5B2453E00E00B19A1D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2521
B505EA5E2453E00E00B19A1D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2622
B505EA602453E00E00B19A1D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -57,9 +53,7 @@
5753
isa = PBXGroup;
5854
children = (
5955
B505EA522453E00D00B19A1D /* AppDelegate.swift */,
60-
B505EA542453E00D00B19A1D /* SceneDelegate.swift */,
6156
B505EA562453E00D00B19A1D /* ViewController.swift */,
62-
B505EA582453E00D00B19A1D /* Main.storyboard */,
6357
B505EA5B2453E00E00B19A1D /* Assets.xcassets */,
6458
B505EA5D2453E00E00B19A1D /* LaunchScreen.storyboard */,
6559
B505EA602453E00E00B19A1D /* Info.plist */,
@@ -127,7 +121,6 @@
127121
files = (
128122
B505EA5F2453E00E00B19A1D /* LaunchScreen.storyboard in Resources */,
129123
B505EA5C2453E00E00B19A1D /* Assets.xcassets in Resources */,
130-
B505EA5A2453E00D00B19A1D /* Main.storyboard in Resources */,
131124
);
132125
runOnlyForDeploymentPostprocessing = 0;
133126
};
@@ -140,21 +133,12 @@
140133
files = (
141134
B505EA572453E00D00B19A1D /* ViewController.swift in Sources */,
142135
B505EA532453E00D00B19A1D /* AppDelegate.swift in Sources */,
143-
B505EA552453E00D00B19A1D /* SceneDelegate.swift in Sources */,
144136
);
145137
runOnlyForDeploymentPostprocessing = 0;
146138
};
147139
/* End PBXSourcesBuildPhase section */
148140

149141
/* Begin PBXVariantGroup section */
150-
B505EA582453E00D00B19A1D /* Main.storyboard */ = {
151-
isa = PBXVariantGroup;
152-
children = (
153-
B505EA592453E00D00B19A1D /* Base */,
154-
);
155-
name = Main.storyboard;
156-
sourceTree = "<group>";
157-
};
158142
B505EA5D2453E00E00B19A1D /* LaunchScreen.storyboard */ = {
159143
isa = PBXVariantGroup;
160144
children = (

SearchController/AppDelegate.swift

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,18 @@
1-
//
2-
// AppDelegate.swift
3-
// SearchController
4-
//
5-
// Created by James Power on 4/24/20.
6-
// Copyright © 2020 James Power. All rights reserved.
7-
//
8-
91
import UIKit
102

113
@UIApplicationMain
124
class AppDelegate: UIResponder, UIApplicationDelegate {
135

14-
6+
var window: UIWindow?
157

168
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
17-
// Override point for customization after application launch.
18-
return true
19-
}
209

21-
// MARK: UISceneSession Lifecycle
10+
window = UIWindow(frame: UIScreen.main.bounds)
11+
window!.rootViewController = UINavigationController(rootViewController: ViewController())
12+
window!.makeKeyAndVisible()
2213

23-
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
24-
// Called when a new scene session is being created.
25-
// Use this method to select a configuration to create the new scene with.
26-
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
27-
}
28-
29-
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
30-
// Called when the user discards a scene session.
31-
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
32-
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
14+
return true
3315
}
3416

35-
3617
}
3718

SearchController/Base.lproj/Main.storyboard

Lines changed: 0 additions & 24 deletions
This file was deleted.

SearchController/Info.plist

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,8 @@
2020
<string>1</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
23-
<key>UIApplicationSceneManifest</key>
24-
<dict>
25-
<key>UIApplicationSupportsMultipleScenes</key>
26-
<false/>
27-
<key>UISceneConfigurations</key>
28-
<dict>
29-
<key>UIWindowSceneSessionRoleApplication</key>
30-
<array>
31-
<dict>
32-
<key>UISceneConfigurationName</key>
33-
<string>Default Configuration</string>
34-
<key>UISceneDelegateClassName</key>
35-
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
36-
<key>UISceneStoryboardFile</key>
37-
<string>Main</string>
38-
</dict>
39-
</array>
40-
</dict>
41-
</dict>
4223
<key>UILaunchStoryboardName</key>
4324
<string>LaunchScreen</string>
44-
<key>UIMainStoryboardFile</key>
45-
<string>Main</string>
4625
<key>UIRequiredDeviceCapabilities</key>
4726
<array>
4827
<string>armv7</string>

SearchController/SceneDelegate.swift

Lines changed: 0 additions & 53 deletions
This file was deleted.

SearchController/ViewController.swift

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
//
2-
// ViewController.swift
3-
// SearchController
4-
//
5-
// Created by James Power on 4/24/20.
6-
// Copyright © 2020 James Power. All rights reserved.
7-
//
8-
91
import UIKit
102

11-
class ViewController: UIViewController {
3+
class ViewController: UITableViewController {
4+
5+
private let searchController = UISearchController(searchResultsController: nil)
126

137
override func viewDidLoad() {
148
super.viewDidLoad()
15-
// Do any additional setup after loading the view.
9+
10+
searchController.searchBar.scopeButtonTitles = ["Scope 1", "Scope 2"]
11+
navigationItem.searchController = searchController
1612
}
1713

14+
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
15+
return 100
16+
}
17+
18+
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
19+
let cell = UITableViewCell()
20+
cell.textLabel?.text = "Row \(indexPath.row)"
21+
return cell
22+
}
1823

1924
}
2025

0 commit comments

Comments
 (0)