Skip to content

Commit c3d669a

Browse files
authored
Merge pull request #17 from jeantimex/remove-main-storyboard-in-example
Removed main storyboard.
2 parents b26f006 + 0378f5d commit c3d669a

7 files changed

Lines changed: 27 additions & 147 deletions

File tree

CollapsibleTableSectionViewController.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = "CollapsibleTableSectionViewController"
19-
s.version = "0.0.7"
19+
s.version = "0.0.8"
2020
s.summary = "Swift 3.0 library to support collapsible sections in a table view."
2121

2222
# This description is used to generate tags and improve search results.

CollapsibleTableSectionViewController/CollapsibleTableViewHeader.swift

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,29 @@ class CollapsibleTableViewHeader: UITableViewHeaderFooterView {
2323
override init(reuseIdentifier: String?) {
2424
super.init(reuseIdentifier: reuseIdentifier)
2525

26-
//
27-
// Constraint the size of arrow label for auto layout
28-
//
29-
arrowLabel.widthAnchor.constraint(equalToConstant: 12).isActive = true
26+
// Content View
27+
contentView.backgroundColor = UIColor(hex: 0x2E3944)
3028

31-
titleLabel.translatesAutoresizingMaskIntoConstraints = false
29+
30+
let marginGuide = contentView.layoutMarginsGuide
31+
32+
// Arrow label
33+
contentView.addSubview(arrowLabel)
34+
arrowLabel.textColor = UIColor.white
3235
arrowLabel.translatesAutoresizingMaskIntoConstraints = false
36+
arrowLabel.widthAnchor.constraint(equalToConstant: 12).isActive = true
37+
arrowLabel.topAnchor.constraint(equalTo: marginGuide.topAnchor).isActive = true
38+
arrowLabel.trailingAnchor.constraint(equalTo: marginGuide.trailingAnchor).isActive = true
39+
arrowLabel.bottomAnchor.constraint(equalTo: marginGuide.bottomAnchor).isActive = true
3340

41+
// Title label
3442
contentView.addSubview(titleLabel)
35-
contentView.addSubview(arrowLabel)
43+
titleLabel.textColor = UIColor.white
44+
titleLabel.translatesAutoresizingMaskIntoConstraints = false
45+
titleLabel.topAnchor.constraint(equalTo: marginGuide.topAnchor).isActive = true
46+
titleLabel.trailingAnchor.constraint(equalTo: marginGuide.trailingAnchor).isActive = true
47+
titleLabel.bottomAnchor.constraint(equalTo: marginGuide.bottomAnchor).isActive = true
48+
titleLabel.leadingAnchor.constraint(equalTo: marginGuide.leadingAnchor).isActive = true
3649

3750
//
3851
// Call tapHeader when tapping on this header
@@ -44,44 +57,6 @@ class CollapsibleTableViewHeader: UITableViewHeaderFooterView {
4457
fatalError("init(coder:) has not been implemented")
4558
}
4659

47-
override func layoutSubviews() {
48-
super.layoutSubviews()
49-
50-
contentView.backgroundColor = UIColor(hex: 0x2E3944)
51-
52-
titleLabel.textColor = UIColor.white
53-
arrowLabel.textColor = UIColor.white
54-
55-
//
56-
// Autolayout the lables
57-
//
58-
let views = [
59-
"titleLabel" : titleLabel,
60-
"arrowLabel" : arrowLabel,
61-
]
62-
63-
contentView.addConstraints(NSLayoutConstraint.constraints(
64-
withVisualFormat: "H:|-20-[titleLabel]-[arrowLabel]-20-|",
65-
options: [],
66-
metrics: nil,
67-
views: views
68-
))
69-
70-
contentView.addConstraints(NSLayoutConstraint.constraints(
71-
withVisualFormat: "V:|-[titleLabel]-|",
72-
options: [],
73-
metrics: nil,
74-
views: views
75-
))
76-
77-
contentView.addConstraints(NSLayoutConstraint.constraints(
78-
withVisualFormat: "V:|-[arrowLabel]-|",
79-
options: [],
80-
metrics: nil,
81-
views: views
82-
))
83-
}
84-
8560
//
8661
// Trigger toggle section when tapping on the header
8762
//

Examples/Examples.xcodeproj/project.pbxproj

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
/* Begin PBXBuildFile section */
1010
0AC886DF1F226627007E4E2F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC886DE1F226627007E4E2F /* AppDelegate.swift */; };
1111
0AC886E11F226627007E4E2F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AC886E01F226627007E4E2F /* ViewController.swift */; };
12-
0AC886E41F226627007E4E2F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0AC886E21F226627007E4E2F /* Main.storyboard */; };
1312
0AC886E61F226627007E4E2F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0AC886E51F226627007E4E2F /* Assets.xcassets */; };
1413
0AC886E91F226627007E4E2F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0AC886E71F226627007E4E2F /* LaunchScreen.storyboard */; };
1514
1954D61128E2AEA6960297AB /* Pods_Examples.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 540185A9FAB3B385AE8ED8A6 /* Pods_Examples.framework */; };
@@ -19,7 +18,6 @@
1918
0AC886DB1F226627007E4E2F /* Examples.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Examples.app; sourceTree = BUILT_PRODUCTS_DIR; };
2019
0AC886DE1F226627007E4E2F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2120
0AC886E01F226627007E4E2F /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
22-
0AC886E31F226627007E4E2F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
2321
0AC886E51F226627007E4E2F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2422
0AC886E81F226627007E4E2F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2523
0AC886EA1F226627007E4E2F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -63,7 +61,6 @@
6361
children = (
6462
0AC886DE1F226627007E4E2F /* AppDelegate.swift */,
6563
0AC886E01F226627007E4E2F /* ViewController.swift */,
66-
0AC886E21F226627007E4E2F /* Main.storyboard */,
6764
0AC886E51F226627007E4E2F /* Assets.xcassets */,
6865
0AC886E71F226627007E4E2F /* LaunchScreen.storyboard */,
6966
0AC886EA1F226627007E4E2F /* Info.plist */,
@@ -153,7 +150,6 @@
153150
files = (
154151
0AC886E91F226627007E4E2F /* LaunchScreen.storyboard in Resources */,
155152
0AC886E61F226627007E4E2F /* Assets.xcassets in Resources */,
156-
0AC886E41F226627007E4E2F /* Main.storyboard in Resources */,
157153
);
158154
runOnlyForDeploymentPostprocessing = 0;
159155
};
@@ -220,14 +216,6 @@
220216
/* End PBXSourcesBuildPhase section */
221217

222218
/* Begin PBXVariantGroup section */
223-
0AC886E21F226627007E4E2F /* Main.storyboard */ = {
224-
isa = PBXVariantGroup;
225-
children = (
226-
0AC886E31F226627007E4E2F /* Base */,
227-
);
228-
name = Main.storyboard;
229-
sourceTree = "<group>";
230-
};
231219
0AC886E71F226627007E4E2F /* LaunchScreen.storyboard */ = {
232220
isa = PBXVariantGroup;
233221
children = (

Examples/Examples/AppDelegate.swift

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1313

1414
var window: UIWindow?
1515

16-
1716
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
1817
// Override point for customization after application launch.
18+
self.window = UIWindow(frame:UIScreen.main.bounds)
19+
self.window?.backgroundColor = UIColor.white
20+
self.window?.rootViewController = UINavigationController(rootViewController: ViewController())
21+
self.window?.makeKeyAndVisible()
22+
1923
return true
2024
}
2125

22-
func applicationWillResignActive(_ application: UIApplication) {
23-
// 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.
24-
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25-
}
26-
27-
func applicationDidEnterBackground(_ application: UIApplication) {
28-
// 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.
29-
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30-
}
31-
32-
func applicationWillEnterForeground(_ application: UIApplication) {
33-
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34-
}
35-
36-
func applicationDidBecomeActive(_ application: UIApplication) {
37-
// 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.
38-
}
39-
40-
func applicationWillTerminate(_ application: UIApplication) {
41-
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42-
}
43-
44-
4526
}
4627

Examples/Examples/Base.lproj/Main.storyboard

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

Examples/Examples/Info.plist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
<true/>
2323
<key>UILaunchStoryboardName</key>
2424
<string>LaunchScreen</string>
25-
<key>UIMainStoryboardFile</key>
26-
<string>Main</string>
2725
<key>UIRequiredDeviceCapabilities</key>
2826
<array>
2927
<string>armv7</string>

Examples/Examples/ViewController.swift

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@
99
import UIKit
1010
import CollapsibleTableSectionViewController
1111

12-
class ViewController: UIViewController {
13-
14-
var sections = [Section]()
12+
class ViewController: CollapsibleTableSectionViewController {
1513

1614
override func viewDidLoad() {
1715
super.viewDidLoad()
1816

1917
self.title = "Apple Products"
2018

21-
let controller: CollapsibleTableSectionViewController = CollapsibleTableSectionViewController()
22-
23-
controller.sections = [
19+
self.sections = [
2420
Section(name: "Mac", items: [
2521
Item(name: "MacBook", detail: "Apple's ultraportable laptop, trading portability for speed and connectivity."),
2622
Item(name: "MacBook Air", detail: "While the screen could be sharper, the updated 11-inch MacBook Air is a very light ultraportable that offers great performance and battery life for the price."),
@@ -44,15 +40,6 @@ class ViewController: UIViewController {
4440
Item(name: "Accessories", detail: "")
4541
])
4642
]
47-
48-
let tableView: UITableView = controller.tableView
49-
50-
var frame = self.view.bounds
51-
frame.origin.y = (navigationController?.navigationBar.frame.maxY)!
52-
53-
tableView.frame = frame
54-
55-
view.addSubview(tableView)
5643
}
5744

5845
}

0 commit comments

Comments
 (0)