|
9 | 9 | import UIKit |
10 | 10 |
|
11 | 11 | class ViewController: UIViewController { |
12 | | - |
| 12 | + |
| 13 | + var sections = [Section]() |
| 14 | + |
13 | 15 | override func viewDidLoad() { |
14 | 16 | super.viewDidLoad() |
15 | | - // Do any additional setup after loading the view, typically from a nib. |
16 | | - } |
17 | | - |
18 | | - override func didReceiveMemoryWarning() { |
19 | | - super.didReceiveMemoryWarning() |
20 | | - // Dispose of any resources that can be recreated. |
| 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) |
21 | 55 | } |
22 | | - |
23 | | - |
| 56 | + |
24 | 57 | } |
25 | 58 |
|
0 commit comments