Skip to content

Commit dcd0431

Browse files
authored
Merge pull request #3 from jeantimex/update-example
Updated example.
2 parents 4af4c46 + b66d480 commit dcd0431

3 files changed

Lines changed: 69 additions & 40 deletions

File tree

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="qHw-Ra-dgm">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
59
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
610
</dependencies>
711
<scenes>
812
<!--View Controller-->
913
<scene sceneID="tne-QT-ifu">
1014
<objects>
11-
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
15+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="CollapsibleTableSectionViewController" customModuleProvider="target" sceneMemberID="viewController">
1216
<layoutGuides>
1317
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
1418
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
@@ -18,9 +22,29 @@
1822
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1923
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2024
</view>
25+
<navigationItem key="navigationItem" id="Q09-RF-lnl"/>
2126
</viewController>
2227
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
2328
</objects>
29+
<point key="canvasLocation" x="863.20000000000005" y="119.1904047976012"/>
30+
</scene>
31+
<!--Navigation Controller-->
32+
<scene sceneID="l1H-B9-Ugr">
33+
<objects>
34+
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="qHw-Ra-dgm" sceneMemberID="viewController">
35+
<toolbarItems/>
36+
<navigationBar key="navigationBar" contentMode="scaleToFill" id="WoY-0u-X9z">
37+
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
38+
<autoresizingMask key="autoresizingMask"/>
39+
</navigationBar>
40+
<nil name="viewControllers"/>
41+
<connections>
42+
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="eLO-86-cG5"/>
43+
</connections>
44+
</navigationController>
45+
<placeholder placeholderIdentifier="IBFirstResponder" id="Po5-l5-gCY" userLabel="First Responder" sceneMemberID="firstResponder"/>
46+
</objects>
47+
<point key="canvasLocation" x="-287" y="119"/>
2448
</scene>
2549
</scenes>
2650
</document>

CollapsibleTableSectionViewController/CollapsibleTableSectionViewController.swift

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,6 @@ class CollapsibleTableSectionViewController: UITableViewController {
4646
// Auto resizing the height of the cell
4747
tableView.estimatedRowHeight = 44.0
4848
tableView.rowHeight = UITableViewAutomaticDimension
49-
50-
self.title = "Apple Products"
51-
52-
// Initialize the sections array
53-
// Here we have three sections: Mac, iPad, iPhone
54-
sections = [
55-
Section(name: "Mac", items: [
56-
Item(name: "MacBook", detail: "Apple's ultraportable laptop, trading portability for speed and connectivity."),
57-
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."),
58-
Item(name: "MacBook Pro", detail: "Retina Display The brightest, most colorful Mac notebook display ever. The display in the MacBook Pro is the best ever in a Mac notebook."),
59-
Item(name: "iMac", detail: "iMac combines enhanced performance with our best ever Retina display for the ultimate desktop experience in two sizes."),
60-
Item(name: "Mac Pro", detail: "Mac Pro is equipped with pro-level graphics, storage, expansion, processing power, and memory. It's built for creativity on an epic scale."),
61-
Item(name: "Mac mini", detail: "Mac mini is an affordable powerhouse that packs the entire Mac experience into a 7.7-inch-square frame."),
62-
Item(name: "OS X El Capitan", detail: "The twelfth major release of OS X (now named macOS)."),
63-
Item(name: "Accessories", detail: "")
64-
]),
65-
Section(name: "iPad", items: [
66-
Item(name: "iPad Pro", detail: "iPad Pro delivers epic power, in 12.9-inch and a new 10.5-inch size."),
67-
Item(name: "iPad Air 2", detail: "The second-generation iPad Air tablet computer designed, developed, and marketed by Apple Inc."),
68-
Item(name: "iPad mini 4", detail: "iPad mini 4 puts uncompromising performance and potential in your hand."),
69-
Item(name: "Accessories", detail: "")
70-
]),
71-
Section(name: "iPhone", items: [
72-
Item(name: "iPhone 6s", detail: "The iPhone 6S has a similar design to the 6 but updated hardware, including a strengthened chassis and upgraded system-on-chip, a 12-megapixel camera, improved fingerprint recognition sensor, and LTE Advanced support."),
73-
Item(name: "iPhone 6", detail: "The iPhone 6 and iPhone 6 Plus are smartphones designed and marketed by Apple Inc."),
74-
Item(name: "iPhone SE", detail: "The iPhone SE was received positively by critics, who noted its familiar form factor and design, improved hardware over previous 4-inch iPhone models, as well as its overall performance and battery life."),
75-
Item(name: "Accessories", detail: "")
76-
])
77-
]
7849
}
7950

8051
}

CollapsibleTableSectionViewController/ViewController.swift

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,51 @@
99
import UIKit
1010

1111
class ViewController: UIViewController {
12+
13+
var sections = [Section]()
1214

1315
override func viewDidLoad() {
1416
super.viewDidLoad()
15-
// Do any additional setup after loading the view, typically from a nib.
17+
18+
self.title = "Apple Products"
19+
20+
let controller: CollapsibleTableSectionViewController = CollapsibleTableSectionViewController()
21+
22+
controller.sections = [
23+
Section(name: "Mac", items: [
24+
Item(name: "MacBook", detail: "Apple's ultraportable laptop, trading portability for speed and connectivity."),
25+
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."),
26+
Item(name: "MacBook Pro", detail: "Retina Display The brightest, most colorful Mac notebook display ever. The display in the MacBook Pro is the best ever in a Mac notebook."),
27+
Item(name: "iMac", detail: "iMac combines enhanced performance with our best ever Retina display for the ultimate desktop experience in two sizes."),
28+
Item(name: "Mac Pro", detail: "Mac Pro is equipped with pro-level graphics, storage, expansion, processing power, and memory. It's built for creativity on an epic scale."),
29+
Item(name: "Mac mini", detail: "Mac mini is an affordable powerhouse that packs the entire Mac experience into a 7.7-inch-square frame."),
30+
Item(name: "OS X El Capitan", detail: "The twelfth major release of OS X (now named macOS)."),
31+
Item(name: "Accessories", detail: "")
32+
]),
33+
Section(name: "iPad", items: [
34+
Item(name: "iPad Pro", detail: "iPad Pro delivers epic power, in 12.9-inch and a new 10.5-inch size."),
35+
Item(name: "iPad Air 2", detail: "The second-generation iPad Air tablet computer designed, developed, and marketed by Apple Inc."),
36+
Item(name: "iPad mini 4", detail: "iPad mini 4 puts uncompromising performance and potential in your hand."),
37+
Item(name: "Accessories", detail: "")
38+
]),
39+
Section(name: "iPhone", items: [
40+
Item(name: "iPhone 6s", detail: "The iPhone 6S has a similar design to the 6 but updated hardware, including a strengthened chassis and upgraded system-on-chip, a 12-megapixel camera, improved fingerprint recognition sensor, and LTE Advanced support."),
41+
Item(name: "iPhone 6", detail: "The iPhone 6 and iPhone 6 Plus are smartphones designed and marketed by Apple Inc."),
42+
Item(name: "iPhone SE", detail: "The iPhone SE was received positively by critics, who noted its familiar form factor and design, improved hardware over previous 4-inch iPhone models, as well as its overall performance and battery life."),
43+
Item(name: "Accessories", detail: "")
44+
])
45+
]
46+
47+
let tableView: UITableView = controller.tableView
48+
49+
var frame = self.view.bounds
50+
frame.origin.y = (navigationController?.navigationBar.frame.maxY)!
51+
52+
tableView.frame = frame
53+
54+
view.addSubview(tableView)
1655
}
1756

18-
override func didReceiveMemoryWarning() {
19-
super.didReceiveMemoryWarning()
20-
// Dispose of any resources that can be recreated.
21-
}
22-
23-
2457
}
2558

59+

0 commit comments

Comments
 (0)