Skip to content

Commit c398952

Browse files
committed
Set up a table view controller in storyboard
1 parent a194373 commit c398952

4 files changed

Lines changed: 143 additions & 0 deletions

File tree

Example/Example.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
B548C5A91C8D6150009D5AEE /* ExampleCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B548C5A81C8D6150009D5AEE /* ExampleCell.swift */; };
1414
B548C5C51C8E91B0009D5AEE /* ICInputAccessoryUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B548C5C41C8E91B0009D5AEE /* ICInputAccessoryUITests.swift */; };
1515
B5C53E191C92851400AF3489 /* CustomizedTokenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C53E181C92851400AF3489 /* CustomizedTokenViewController.swift */; };
16+
B5D04CFE1C99A7C900174823 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B5D04CFD1C99A7C900174823 /* Main.storyboard */; };
17+
B5D04D001C99AF0700174823 /* StoryboardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D04CFF1C99AF0700174823 /* StoryboardViewController.swift */; };
1618
B5E9F8FF1C8D3B6E00443DC7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E9F8FE1C8D3B6E00443DC7 /* AppDelegate.swift */; };
1719
B5E9F9011C8D3B6E00443DC7 /* ExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E9F9001C8D3B6E00443DC7 /* ExampleViewController.swift */; };
1820
B5E9F9061C8D3B6E00443DC7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B5E9F9051C8D3B6E00443DC7 /* Assets.xcassets */; };
@@ -37,6 +39,8 @@
3739
B548C5C41C8E91B0009D5AEE /* ICInputAccessoryUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ICInputAccessoryUITests.swift; sourceTree = "<group>"; };
3840
B548C5C61C8E91B0009D5AEE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3941
B5C53E181C92851400AF3489 /* CustomizedTokenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomizedTokenViewController.swift; sourceTree = "<group>"; };
42+
B5D04CFD1C99A7C900174823 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
43+
B5D04CFF1C99AF0700174823 /* StoryboardViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoryboardViewController.swift; sourceTree = "<group>"; };
4044
B5E9F8FB1C8D3B6E00443DC7 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
4145
B5E9F8FE1C8D3B6E00443DC7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
4246
B5E9F9001C8D3B6E00443DC7 /* ExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleViewController.swift; sourceTree = "<group>"; };
@@ -125,6 +129,8 @@
125129
B5E9F90A1C8D3B6E00443DC7 /* Info.plist */,
126130
B548C5A51C8D55A8009D5AEE /* InfoPlist.strings */,
127131
B5E9F9071C8D3B6E00443DC7 /* LaunchScreen.storyboard */,
132+
B5D04CFD1C99A7C900174823 /* Main.storyboard */,
133+
B5D04CFF1C99AF0700174823 /* StoryboardViewController.swift */,
128134
);
129135
path = Example;
130136
sourceTree = "<group>";
@@ -224,6 +230,7 @@
224230
B5E9F9061C8D3B6E00443DC7 /* Assets.xcassets in Resources */,
225231
B548C5A71C8D55A8009D5AEE /* InfoPlist.strings in Resources */,
226232
B5E9F9091C8D3B6E00443DC7 /* LaunchScreen.storyboard in Resources */,
233+
B5D04CFE1C99A7C900174823 /* Main.storyboard in Resources */,
227234
);
228235
runOnlyForDeploymentPostprocessing = 0;
229236
};
@@ -309,6 +316,7 @@
309316
B5C53E191C92851400AF3489 /* CustomizedTokenViewController.swift in Sources */,
310317
B548C5A91C8D6150009D5AEE /* ExampleCell.swift in Sources */,
311318
B5E9F9011C8D3B6E00443DC7 /* ExampleViewController.swift in Sources */,
319+
B5D04D001C99AF0700174823 /* StoryboardViewController.swift in Sources */,
312320
);
313321
runOnlyForDeploymentPostprocessing = 0;
314322
};

Example/Example/ExampleViewController.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ class ExampleViewController: UITableViewController {
3535
CustomizedTokenField.self
3636
]
3737

38+
private lazy var flipButton: UIButton = {
39+
let _button = UIButton(type: .System)
40+
_button.frame = CGRect(x: 0, y: 0, width: UIScreen.mainScreen().bounds.width, height: 88)
41+
_button.setTitle("Storyboard", forState: .Normal)
42+
_button.addTarget(self, action: Selector("showStoryboard:"), forControlEvents: .TouchUpInside)
43+
return _button
44+
}()
45+
3846
// MARK: - Initialization
3947

4048
convenience init() {
@@ -47,6 +55,8 @@ class ExampleViewController: UITableViewController {
4755
override func loadView() {
4856
super.loadView()
4957
tableView.registerClass(ExampleCell.self, forCellReuseIdentifier: NSStringFromClass(ExampleCell.self))
58+
tableView.tableFooterView = flipButton
59+
tableView.tableFooterView?.userInteractionEnabled
5060
}
5161

5262
// MARK: - UITableViewDataSource
@@ -113,4 +123,13 @@ class ExampleViewController: UITableViewController {
113123
}
114124
}
115125

126+
// MARK: - UIResponder Callbacks
127+
128+
@IBAction private func showStoryboard(sender: UIButton) {
129+
if let controller = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()).instantiateInitialViewController() {
130+
controller.modalTransitionStyle = .FlipHorizontal
131+
presentViewController(controller, animated: true, completion: nil)
132+
}
133+
}
134+
116135
}

Example/Example/Main.storyboard

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="XY5-gz-UXC">
3+
<dependencies>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
6+
</dependencies>
7+
<scenes>
8+
<!--ICInputAccessory-->
9+
<scene sceneID="ssv-qC-OfH">
10+
<objects>
11+
<tableViewController id="0fq-Xw-Z0G" customClass="StoryboardViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
12+
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="ZTV-zA-HhW">
13+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
14+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
15+
<color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="calibratedRGB"/>
16+
<button key="tableFooterView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="N87-CU-PrP">
17+
<rect key="frame" x="0.0" y="269.5" width="600" height="88"/>
18+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
19+
<fontDescription key="fontDescription" type="system" pointSize="15"/>
20+
<state key="normal" title="Back"/>
21+
<connections>
22+
<action selector="dismiss:" destination="0fq-Xw-Z0G" eventType="touchUpInside" id="Ia6-YR-Zzm"/>
23+
</connections>
24+
</button>
25+
<sections>
26+
<tableViewSection headerTitle="Dismiss Keyboard" id="tmE-Ln-PNX">
27+
<cells>
28+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="hiq-lt-L5I">
29+
<rect key="frame" x="0.0" y="113.5" width="600" height="44"/>
30+
<autoresizingMask key="autoresizingMask"/>
31+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="hiq-lt-L5I" id="dNb-Qm-7pq">
32+
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
33+
<autoresizingMask key="autoresizingMask"/>
34+
</tableViewCellContentView>
35+
</tableViewCell>
36+
</cells>
37+
</tableViewSection>
38+
<tableViewSection headerTitle="Text Field with Tokens" id="dx2-iZ-OPN">
39+
<cells>
40+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="nCe-ZG-eEP">
41+
<rect key="frame" x="0.0" y="207.5" width="600" height="44"/>
42+
<autoresizingMask key="autoresizingMask"/>
43+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="nCe-ZG-eEP" id="6tu-Im-VHX">
44+
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
45+
<autoresizingMask key="autoresizingMask"/>
46+
</tableViewCellContentView>
47+
</tableViewCell>
48+
</cells>
49+
</tableViewSection>
50+
</sections>
51+
<connections>
52+
<outlet property="dataSource" destination="0fq-Xw-Z0G" id="dzH-mw-zz6"/>
53+
<outlet property="delegate" destination="0fq-Xw-Z0G" id="x9o-bW-6Q0"/>
54+
</connections>
55+
</tableView>
56+
<navigationItem key="navigationItem" title="ICInputAccessory" id="Q3g-An-b4N"/>
57+
</tableViewController>
58+
<placeholder placeholderIdentifier="IBFirstResponder" id="4Lj-fL-J07" userLabel="First Responder" sceneMemberID="firstResponder"/>
59+
</objects>
60+
<point key="canvasLocation" x="1520" y="377"/>
61+
</scene>
62+
<!--Navigation Controller-->
63+
<scene sceneID="ee2-Ek-31J">
64+
<objects>
65+
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="XY5-gz-UXC" sceneMemberID="viewController">
66+
<toolbarItems/>
67+
<navigationBar key="navigationBar" contentMode="scaleToFill" id="wet-wK-15h">
68+
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
69+
<autoresizingMask key="autoresizingMask"/>
70+
</navigationBar>
71+
<nil name="viewControllers"/>
72+
<connections>
73+
<segue destination="0fq-Xw-Z0G" kind="relationship" relationship="rootViewController" id="eaz-Pe-xkY"/>
74+
</connections>
75+
</navigationController>
76+
<placeholder placeholderIdentifier="IBFirstResponder" id="QTj-zS-BEl" userLabel="First Responder" sceneMemberID="firstResponder"/>
77+
</objects>
78+
<point key="canvasLocation" x="708" y="377"/>
79+
</scene>
80+
</scenes>
81+
</document>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// StoryboardViewController.swift
3+
// Example
4+
//
5+
// Created by Ben on 16/03/2016.
6+
// Copyright © 2016 Polydice, Inc.
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
//
26+
27+
import UIKit
28+
29+
class StoryboardViewController: UITableViewController {
30+
31+
@IBAction func dismiss(sender: UIButton) {
32+
presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
33+
}
34+
35+
}

0 commit comments

Comments
 (0)