Skip to content

Commit 6ccd27b

Browse files
committed
Added iOS8 Swift example
1 parent 174bc0a commit 6ccd27b

23 files changed

+1620
-0
lines changed

Examples/SwiftExamples/SwiftExamples.xcodeproj/project.pbxproj

+499
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// AppDelegate.swift
3+
// SwiftExamples
4+
//
5+
// Created by Erik Doernenburg on 11/06/2014.
6+
// Copyright (c) 2014 Mulle Kybernetik. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
@UIApplicationMain
12+
class AppDelegate: UIResponder, UIApplicationDelegate {
13+
14+
var window: UIWindow?
15+
16+
17+
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
18+
// Override point for customization after application launch.
19+
let splitViewController = self.window!.rootViewController as UISplitViewController
20+
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.endIndex-1] as UINavigationController
21+
splitViewController.delegate = navigationController.topViewController as DetailViewController
22+
return true
23+
}
24+
25+
func applicationWillResignActive(application: UIApplication) {
26+
// 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.
27+
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
28+
}
29+
30+
func applicationDidEnterBackground(application: UIApplication) {
31+
// 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.
32+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33+
}
34+
35+
func applicationWillEnterForeground(application: UIApplication) {
36+
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
37+
}
38+
39+
func applicationDidBecomeActive(application: UIApplication) {
40+
// 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.
41+
}
42+
43+
func applicationWillTerminate(application: UIApplication) {
44+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
45+
}
46+
47+
48+
}
49+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6162" systemVersion="14A238h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="H1p-Uh-vWS">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6160"/>
5+
</dependencies>
6+
<scenes>
7+
<!--Navigation Controller-->
8+
<scene sceneID="pY4-Hu-kfo">
9+
<objects>
10+
<navigationController id="RMx-3f-FxP" sceneMemberID="viewController">
11+
<navigationBar key="navigationBar" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="Pmd-2v-anx">
12+
<autoresizingMask key="autoresizingMask"/>
13+
</navigationBar>
14+
<connections>
15+
<segue destination="7bK-jq-Zjz" kind="relationship" relationship="rootViewController" id="tsl-Nk-0bq"/>
16+
</connections>
17+
</navigationController>
18+
<placeholder placeholderIdentifier="IBFirstResponder" id="8fS-aE-onr" sceneMemberID="firstResponder"/>
19+
</objects>
20+
<point key="canvasLocation" x="-38" y="-630"/>
21+
</scene>
22+
<!--Detail View Controller - Detail-->
23+
<scene sceneID="yUG-lL-AsK">
24+
<objects>
25+
<viewController title="Detail" id="JEX-9P-axG" customClass="DetailViewController" customModuleProvider="target" sceneMemberID="viewController">
26+
<layoutGuides>
27+
<viewControllerLayoutGuide type="top" id="SYR-Wa-9uf"/>
28+
<viewControllerLayoutGuide type="bottom" id="GAO-Cl-Wes"/>
29+
</layoutGuides>
30+
<view key="view" contentMode="scaleToFill" id="svH-Pt-448">
31+
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
32+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
33+
<subviews>
34+
<label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Detail view content goes here" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="0XM-y9-sOw">
35+
<rect key="frame" x="20" y="232" width="440" height="17"/>
36+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
37+
<fontDescription key="fontDescription" type="system" size="system"/>
38+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
39+
<nil key="highlightedColor"/>
40+
</label>
41+
</subviews>
42+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
43+
<constraints>
44+
<constraint firstItem="0XM-y9-sOw" firstAttribute="leading" secondItem="svH-Pt-448" secondAttribute="leading" constant="20" symbolic="YES" id="Tsc-yG-G1q"/>
45+
<constraint firstItem="0XM-y9-sOw" firstAttribute="centerY" secondItem="svH-Pt-448" secondAttribute="centerY" id="jWN-iV-94e"/>
46+
<constraint firstAttribute="trailing" secondItem="0XM-y9-sOw" secondAttribute="trailing" constant="20" symbolic="YES" id="tHV-ZD-HQj"/>
47+
</constraints>
48+
</view>
49+
<toolbarItems/>
50+
<navigationItem key="navigationItem" title="Detail" id="mOI-FS-AaM"/>
51+
<connections>
52+
<outlet property="detailDescriptionLabel" destination="0XM-y9-sOw" id="deQ-Na-JPF"/>
53+
</connections>
54+
</viewController>
55+
<placeholder placeholderIdentifier="IBFirstResponder" id="FJe-Yq-33r" sceneMemberID="firstResponder"/>
56+
</objects>
57+
<point key="canvasLocation" x="604" y="30"/>
58+
</scene>
59+
<!--Split View Controller-->
60+
<scene sceneID="Nki-YV-4Qg">
61+
<objects>
62+
<splitViewController id="H1p-Uh-vWS" sceneMemberID="viewController">
63+
<toolbarItems/>
64+
<connections>
65+
<segue destination="RMx-3f-FxP" kind="relationship" relationship="masterViewController" id="BlO-5A-QYV"/>
66+
<segue destination="vC3-pB-5Vb" kind="relationship" relationship="detailViewController" id="Tll-UG-LXB"/>
67+
</connections>
68+
</splitViewController>
69+
<placeholder placeholderIdentifier="IBFirstResponder" id="cZU-Oi-B1e" sceneMemberID="firstResponder"/>
70+
</objects>
71+
<point key="canvasLocation" x="-687" y="-322"/>
72+
</scene>
73+
<!--Master View Controller - Master-->
74+
<scene sceneID="smW-Zh-WAh">
75+
<objects>
76+
<tableViewController title="Master" clearsSelectionOnViewWillAppear="NO" id="7bK-jq-Zjz" customClass="MasterViewController" customModuleProvider="target" sceneMemberID="viewController">
77+
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="r7i-6Z-zg0">
78+
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
79+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
80+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
81+
<prototypes>
82+
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="Arm-wq-HPj" style="IBUITableViewCellStyleDefault" id="WCw-Qf-5nD">
83+
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
84+
<autoresizingMask key="autoresizingMask"/>
85+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="WCw-Qf-5nD" id="37f-cq-3Eg">
86+
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
87+
<autoresizingMask key="autoresizingMask"/>
88+
<subviews>
89+
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Arm-wq-HPj">
90+
<rect key="frame" x="15" y="0.0" width="290" height="43"/>
91+
<autoresizingMask key="autoresizingMask"/>
92+
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
93+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
94+
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
95+
</label>
96+
</subviews>
97+
</tableViewCellContentView>
98+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
99+
<connections>
100+
<segue destination="vC3-pB-5Vb" kind="showDetail" identifier="showDetail" id="6S0-TO-JiA"/>
101+
</connections>
102+
</tableViewCell>
103+
</prototypes>
104+
<sections/>
105+
<connections>
106+
<outlet property="dataSource" destination="7bK-jq-Zjz" id="Gho-Na-rnu"/>
107+
<outlet property="delegate" destination="7bK-jq-Zjz" id="RA6-mI-bju"/>
108+
</connections>
109+
</tableView>
110+
<navigationItem key="navigationItem" title="Master" id="Zdf-7t-Un8"/>
111+
</tableViewController>
112+
<placeholder placeholderIdentifier="IBFirstResponder" id="Rux-fX-hf1" sceneMemberID="firstResponder"/>
113+
</objects>
114+
<point key="canvasLocation" x="604" y="-630"/>
115+
</scene>
116+
<!--Navigation Controller-->
117+
<scene sceneID="r7l-gg-dq7">
118+
<objects>
119+
<navigationController id="vC3-pB-5Vb" sceneMemberID="viewController">
120+
<navigationBar key="navigationBar" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="DjV-YW-jjY">
121+
<autoresizingMask key="autoresizingMask"/>
122+
</navigationBar>
123+
<connections>
124+
<segue destination="JEX-9P-axG" kind="relationship" relationship="rootViewController" id="GKi-kA-LjT"/>
125+
</connections>
126+
</navigationController>
127+
<placeholder placeholderIdentifier="IBFirstResponder" id="SLD-UC-DBI" userLabel="First Responder" sceneMemberID="firstResponder"/>
128+
</objects>
129+
<point key="canvasLocation" x="-38" y="30"/>
130+
</scene>
131+
</scenes>
132+
<inferredMetricsTieBreakers>
133+
<segue reference="6S0-TO-JiA"/>
134+
</inferredMetricsTieBreakers>
135+
</document>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Connection.swift
3+
// SwiftExperiments
4+
//
5+
// Created by Erik D on 05/06/14.
6+
// Copyright (c) 2014 Mulle Kybernetik. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
class Connection : NSObject {
12+
13+
func fetchData() -> String {
14+
return "real data returned from other system"
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Controller.swift
3+
// SwiftExperiments
4+
//
5+
// Created by Erik D on 05/06/14.
6+
// Copyright (c) 2014 Mulle Kybernetik. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
@objc
12+
class Controller {
13+
var connection: Connection;
14+
var data: String;
15+
16+
class func newController() -> Controller {
17+
return Controller()
18+
}
19+
20+
init() {
21+
self.connection = Connection();
22+
self.data = "";
23+
}
24+
25+
func redisplay() {
26+
data = connection.fetchData();
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// DetailViewController.swift
3+
// SwiftExamples
4+
//
5+
// Created by Erik Doernenburg on 11/06/2014.
6+
// Copyright (c) 2014 Mulle Kybernetik. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class DetailViewController: UIViewController, UISplitViewControllerDelegate {
12+
13+
@IBOutlet var detailDescriptionLabel: UILabel
14+
var masterPopoverController: UIPopoverController? = nil
15+
16+
17+
var detailItem: AnyObject? {
18+
didSet {
19+
// Update the view.
20+
self.configureView()
21+
22+
if self.masterPopoverController != nil {
23+
self.masterPopoverController!.dismissPopoverAnimated(true)
24+
}
25+
}
26+
}
27+
28+
func configureView() {
29+
// Update the user interface for the detail item.
30+
if let detail: AnyObject = self.detailItem {
31+
if let label = self.detailDescriptionLabel {
32+
label.text = detail.description
33+
}
34+
}
35+
}
36+
37+
override func viewDidLoad() {
38+
super.viewDidLoad()
39+
// Do any additional setup after loading the view, typically from a nib.
40+
self.configureView()
41+
}
42+
43+
override func didReceiveMemoryWarning() {
44+
super.didReceiveMemoryWarning()
45+
// Dispose of any resources that can be recreated.
46+
}
47+
48+
// #pragma mark - Split view
49+
50+
func splitViewController(splitController: UISplitViewController, willHideViewController viewController: UIViewController, withBarButtonItem barButtonItem: UIBarButtonItem, forPopoverController popoverController: UIPopoverController) {
51+
barButtonItem.title = "Master" // NSLocalizedString(@"Master", @"Master")
52+
self.navigationItem.setLeftBarButtonItem(barButtonItem, animated: true)
53+
self.masterPopoverController = popoverController
54+
}
55+
56+
func splitViewController(splitController: UISplitViewController, willShowViewController viewController: UIViewController, invalidatingBarButtonItem barButtonItem: UIBarButtonItem) {
57+
// Called when the view is shown again in the split view, invalidating the button and popover controller.
58+
self.navigationItem.setLeftBarButtonItem(nil, animated: true)
59+
self.masterPopoverController = nil
60+
}
61+
func splitViewController(splitController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController, ontoPrimaryViewController primaryViewController: UIViewController) -> Bool {
62+
// Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
63+
return true
64+
}
65+
66+
}
67+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "29x29",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "40x40",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"size" : "60x60",
16+
"scale" : "2x"
17+
},
18+
{
19+
"idiom" : "ipad",
20+
"size" : "29x29",
21+
"scale" : "1x"
22+
},
23+
{
24+
"idiom" : "ipad",
25+
"size" : "29x29",
26+
"scale" : "2x"
27+
},
28+
{
29+
"idiom" : "ipad",
30+
"size" : "40x40",
31+
"scale" : "1x"
32+
},
33+
{
34+
"idiom" : "ipad",
35+
"size" : "40x40",
36+
"scale" : "2x"
37+
},
38+
{
39+
"idiom" : "ipad",
40+
"size" : "76x76",
41+
"scale" : "1x"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"size" : "76x76",
46+
"scale" : "2x"
47+
}
48+
],
49+
"info" : {
50+
"version" : 1,
51+
"author" : "xcode"
52+
}
53+
}

0 commit comments

Comments
 (0)