Created
June 12, 2016 16:23
-
-
Save ken0nek/c7aa9488f278d0a92b374514ec4aa17c to your computer and use it in GitHub Desktop.
iOS 9 Sampler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RootViewController.swift | |
// iOS9Sampler | |
// | |
// Created by Shuichi Tsutsumi on 2015/06/10. | |
// Copyright © 2015 Shuichi Tsutsumi. All rights reserved. | |
// | |
import UIKit | |
final class RootViewController: UITableViewController { | |
private let dataSource = SampleDataSource() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
tableView.dataSource = dataSource | |
} | |
override func viewDidAppear(animated: Bool) { | |
// Needed after custome transition | |
navigationController?.delegate = nil; | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
} | |
// ========================================================================= | |
// MARK: - UITableViewDelegate | |
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { | |
return UITableViewAutomaticDimension | |
} | |
override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { | |
return UITableViewAutomaticDimension | |
} | |
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { | |
let sample = dataSource.samples[indexPath.row] | |
navigationController?.pushViewController(sample.controller(), animated: true) | |
tableView.deselectRowAtIndexPath(indexPath, animated: true) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Sample.swift | |
// iOS9Sampler | |
// | |
// Created by Shuichi Tsutsumi on 6/12/16. | |
// Copyright © 2016 Shuichi Tsutsumi. All rights reserved. | |
// | |
import Foundation | |
struct Sample { | |
let title: String | |
let detail: String | |
let classPrefix: String | |
func controller() -> UIViewController { | |
let storyboard = UIStoryboard(name: classPrefix, bundle: nil) | |
guard let controller = storyboard.instantiateInitialViewController() else { fatalError() } | |
controller.title = title | |
return controller | |
} | |
} | |
final class SampleDataSource: NSObject { | |
let samples = [ | |
Sample( | |
title: "Map Customizations", | |
detail: "Flyover can be selected with new map types, and Traffic, Scale and Compass can be shown.", | |
classPrefix: "MapCustomizations" | |
), | |
Sample( | |
title: "Text Detector", | |
detail: "Text detection using new detector type \"CIDetectorTypeText\".", | |
classPrefix: "TextDetect" | |
), | |
Sample( | |
title: "New Image Filters", | |
detail: "New filters of CIFilter which can be used for Still Images.", | |
classPrefix: "StillImageFilters" | |
), | |
Sample( | |
title: "Audio Unit Component Manager", | |
detail: "Retrieve available audio units using AudioUnitComponentManager and apply them to a sound. If there are some Audio Unit Extensions, they will be also shown.", | |
classPrefix: "AudioUnitComponentManager" | |
), | |
Sample( | |
title: "Speech Voices", | |
detail: "Example for new properties which are added to AVSpeechSynthesisVoice such as language, name, quality...", | |
classPrefix: "Speech" | |
), | |
Sample( | |
title: "CASpringAnimation", | |
detail: "Animation example using CASpringAnimation.", | |
classPrefix: "Spring" | |
), | |
Sample( | |
title: "Core Image Transitions", | |
detail: "New transition effects which are added to CITransitionCategory.", | |
classPrefix: "CoreImageTransitions" | |
), | |
Sample( | |
title: "UIStackView", | |
detail: "Auto Layout example using UIStackView.", | |
classPrefix: "StackView" | |
), | |
Sample( | |
title: "Selfies & Screenshots", | |
detail: "Fetch photos filtered with new subtypes \"SelfPortraits\" and \"Screenshot\" which are added to Photos framework.", | |
classPrefix: "Photos" | |
), | |
Sample( | |
title: "String Transform", | |
detail: "String transliteration examples using new APIs of Foundation framework.", | |
classPrefix: "StringTransform" | |
), | |
Sample( | |
title: "Search APIs", | |
detail: "Example for Search APIs using NSUserActivity and Core Spotlight.", | |
classPrefix: "SearchAPIs" | |
), | |
Sample( | |
title: "Content Blockers", | |
detail: "Example for Content Blocker Extension.", | |
classPrefix: "ContentBlocker" | |
), | |
Sample( | |
title: "SFSafariViewController", | |
detail: "Open web pages with SFSafariViewController.", | |
classPrefix: "Safari" | |
), | |
Sample( | |
title: "Attributes of New Filters", | |
detail: "Extract new filters of CIFilter using \"kCIAttributeFilterAvailable_iOS\".", | |
classPrefix: "Filters" | |
), | |
Sample( | |
title: "Low Power Mode", | |
detail: "Detect changes of \"Low Power Mode\" setting.", | |
classPrefix: "LowPowerMode" | |
), | |
Sample( | |
title: "New Fonts", | |
detail: "Gallery of new fonts.", | |
classPrefix: "Fonts" | |
), | |
Sample( | |
title: "Contacts", | |
detail: "Contacts framework sample.", | |
classPrefix: "Contacts" | |
), | |
Sample( | |
title: "ReplayKit", | |
detail: "ReplayKit framework sample.", | |
classPrefix: "ReplayKit" | |
), | |
Sample( | |
title: "Quick Actions", | |
detail: "Access the shortcut menu on the Home screen using 3D Touch.", | |
classPrefix: "QuickActions" | |
), | |
Sample( | |
title: "Force Touch", | |
detail: "Visualize the forces of touches using new properties of UITouch.", | |
classPrefix: "ForceTouch" | |
), | |
Sample( | |
title: "Live Photos", | |
detail: "Show a Live Photo using \"PHLivePhotoView\"", | |
classPrefix: "LivePhoto" | |
), | |
] | |
} | |
// ========================================================================= | |
// MARK: - UITableViewDataSource | |
extension SampleDataSource: UITableViewDataSource { | |
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return samples.count | |
} | |
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { | |
guard let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as? RootViewCell else {fatalError()} | |
let sample = samples[indexPath.row] | |
cell.titleLabel.text = sample.title | |
cell.detailLabel.text = sample.detail | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment