Skip to content

Commit f6e5be2

Browse files
Add support for storyboard-based cells. (Addresses #13)
1 parent f02bc82 commit f6e5be2

File tree

11 files changed

+633
-307
lines changed

11 files changed

+633
-307
lines changed

DNSSwipeableCell.xcodeproj/project.pbxproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
9B2076F51A9FA46C00D08704 /* StoryboardTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B2076F41A9FA46C00D08704 /* StoryboardTableViewController.m */; };
11+
9B2076F81A9FA49400D08704 /* DNSStoryboardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B2076F71A9FA49400D08704 /* DNSStoryboardCell.m */; };
12+
9B2076FB1A9FA6D200D08704 /* SwipeableDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B2076FA1A9FA6D200D08704 /* SwipeableDataSource.m */; };
1013
9BF394EB18C433CD00E1CB12 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 9BF394EA18C433CD00E1CB12 /* README.md */; };
1114
9BF394EE18C58B0600E1CB12 /* DNSExampleImageViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BF394ED18C58B0600E1CB12 /* DNSExampleImageViewCell.m */; };
1215
9BF394F618C58D6300E1CB12 /* annoyed.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 9BF394F018C58D6300E1CB12 /* annoyed.jpg */; };
@@ -44,6 +47,12 @@
4447
/* End PBXContainerItemProxy section */
4548

4649
/* Begin PBXFileReference section */
50+
9B2076F31A9FA46C00D08704 /* StoryboardTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StoryboardTableViewController.h; sourceTree = "<group>"; };
51+
9B2076F41A9FA46C00D08704 /* StoryboardTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StoryboardTableViewController.m; sourceTree = "<group>"; };
52+
9B2076F61A9FA49400D08704 /* DNSStoryboardCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNSStoryboardCell.h; sourceTree = "<group>"; };
53+
9B2076F71A9FA49400D08704 /* DNSStoryboardCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DNSStoryboardCell.m; sourceTree = "<group>"; };
54+
9B2076F91A9FA6D200D08704 /* SwipeableDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SwipeableDataSource.h; sourceTree = "<group>"; };
55+
9B2076FA1A9FA6D200D08704 /* SwipeableDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SwipeableDataSource.m; sourceTree = "<group>"; };
4756
9BF394EA18C433CD00E1CB12 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
4857
9BF394EC18C58B0600E1CB12 /* DNSExampleImageViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNSExampleImageViewCell.h; sourceTree = "<group>"; };
4958
9BF394ED18C58B0600E1CB12 /* DNSExampleImageViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DNSExampleImageViewCell.m; sourceTree = "<group>"; };
@@ -163,10 +172,16 @@
163172
F5C72C16184771F90019502F /* Main.storyboard */,
164173
F5C72C19184771F90019502F /* MasterViewController.h */,
165174
F5C72C1A184771F90019502F /* MasterViewController.m */,
175+
9B2076F31A9FA46C00D08704 /* StoryboardTableViewController.h */,
176+
9B2076F41A9FA46C00D08704 /* StoryboardTableViewController.m */,
166177
F5C72C1C184771F90019502F /* DetailViewController.h */,
167178
F5C72C1D184771F90019502F /* DetailViewController.m */,
179+
9B2076F91A9FA6D200D08704 /* SwipeableDataSource.h */,
180+
9B2076FA1A9FA6D200D08704 /* SwipeableDataSource.m */,
168181
9BF394EC18C58B0600E1CB12 /* DNSExampleImageViewCell.h */,
169182
9BF394ED18C58B0600E1CB12 /* DNSExampleImageViewCell.m */,
183+
9B2076F61A9FA49400D08704 /* DNSStoryboardCell.h */,
184+
9B2076F71A9FA49400D08704 /* DNSStoryboardCell.m */,
170185
9BF394FE18C5A4A000E1CB12 /* Library */,
171186
9BF394EF18C58D6300E1CB12 /* instagrams */,
172187
9BF394FC18C5A0DD00E1CB12 /* Assets.xcassets */,
@@ -312,6 +327,9 @@
312327
F5C72C15184771F90019502F /* AppDelegate.m in Sources */,
313328
F5C72C1B184771F90019502F /* MasterViewController.m in Sources */,
314329
9BF394EE18C58B0600E1CB12 /* DNSExampleImageViewCell.m in Sources */,
330+
9B2076F81A9FA49400D08704 /* DNSStoryboardCell.m in Sources */,
331+
9B2076FB1A9FA6D200D08704 /* SwipeableDataSource.m in Sources */,
332+
9B2076F51A9FA46C00D08704 /* StoryboardTableViewController.m in Sources */,
315333
F5C72C11184771F90019502F /* main.m in Sources */,
316334
F5C72C1E184771F90019502F /* DetailViewController.m in Sources */,
317335
);

DNSSwipeableCell/Base.lproj/Main.storyboard

Lines changed: 106 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4514" systemVersion="13C64" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="rS3-R9-Ivy">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="rS3-R9-Ivy">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
56
</dependencies>
67
<scenes>
78
<!--Navigation Controller-->
@@ -19,7 +20,99 @@
1920
</objects>
2021
<point key="canvasLocation" x="-1" y="64"/>
2122
</scene>
22-
<!--Master View Controller - Master-->
23+
<!--Navigation Controller-->
24+
<scene sceneID="7iq-2G-qwu">
25+
<objects>
26+
<navigationController storyboardIdentifier="StoryboardNav" id="hOt-nD-ora" sceneMemberID="viewController">
27+
<navigationBar key="navigationBar" contentMode="scaleToFill" id="ktk-GY-Ewf">
28+
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
29+
<autoresizingMask key="autoresizingMask"/>
30+
</navigationBar>
31+
<connections>
32+
<segue destination="e6f-rn-fWV" kind="relationship" relationship="rootViewController" id="Rz9-Mh-HZU"/>
33+
</connections>
34+
</navigationController>
35+
<placeholder placeholderIdentifier="IBFirstResponder" id="s9b-fX-omU" userLabel="First Responder" sceneMemberID="firstResponder"/>
36+
</objects>
37+
<point key="canvasLocation" x="90" y="749"/>
38+
</scene>
39+
<!--Storyboard Table View Controller-->
40+
<scene sceneID="qWJ-80-Hgo">
41+
<objects>
42+
<tableViewController storyboardIdentifier="StoryboardTableViewController" id="e6f-rn-fWV" customClass="StoryboardTableViewController" sceneMemberID="viewController">
43+
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="jO1-Gt-T5J">
44+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
45+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
46+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
47+
<prototypes>
48+
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="DNSStoryboardCell" rowHeight="400" id="ZEa-Yc-8yf" customClass="DNSStoryboardCell">
49+
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
50+
<autoresizingMask key="autoresizingMask"/>
51+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ZEa-Yc-8yf" id="8gx-fm-mAn">
52+
<autoresizingMask key="autoresizingMask"/>
53+
<subviews>
54+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="h16-E5-l3y" userLabel="MyContentView">
55+
<rect key="frame" x="0.0" y="0.0" width="320" height="399.5"/>
56+
<subviews>
57+
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ZBn-9o-dpV">
58+
<rect key="frame" x="0.0" y="0.0" width="320" height="320"/>
59+
<constraints>
60+
<constraint firstAttribute="height" constant="320" id="F1Y-00-dWU"/>
61+
<constraint firstAttribute="width" constant="320" id="Hl7-dp-Svt"/>
62+
</constraints>
63+
</imageView>
64+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qMz-vv-1tY">
65+
<rect key="frame" x="20" y="340" width="280" height="39.5"/>
66+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
67+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
68+
<nil key="highlightedColor"/>
69+
</label>
70+
</subviews>
71+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
72+
<constraints>
73+
<constraint firstItem="qMz-vv-1tY" firstAttribute="top" secondItem="ZBn-9o-dpV" secondAttribute="bottom" constant="20" id="Gql-cS-cvq"/>
74+
<constraint firstAttribute="bottom" secondItem="qMz-vv-1tY" secondAttribute="bottom" constant="20" id="TSG-9C-HFD"/>
75+
<constraint firstItem="ZBn-9o-dpV" firstAttribute="top" secondItem="h16-E5-l3y" secondAttribute="top" id="VKf-Je-XNy"/>
76+
<constraint firstAttribute="trailing" secondItem="qMz-vv-1tY" secondAttribute="trailing" constant="20" id="jFV-Wo-Lxn"/>
77+
<constraint firstItem="qMz-vv-1tY" firstAttribute="leading" secondItem="h16-E5-l3y" secondAttribute="leading" constant="20" id="u6W-wj-GwL"/>
78+
<constraint firstAttribute="centerX" secondItem="ZBn-9o-dpV" secondAttribute="centerX" id="uAU-jx-kVb"/>
79+
</constraints>
80+
</view>
81+
</subviews>
82+
<constraints>
83+
<constraint firstAttribute="bottom" secondItem="h16-E5-l3y" secondAttribute="bottom" id="Eoo-NX-bdv"/>
84+
<constraint firstItem="h16-E5-l3y" firstAttribute="top" secondItem="8gx-fm-mAn" secondAttribute="top" id="RKd-t0-AgL"/>
85+
<constraint firstItem="h16-E5-l3y" firstAttribute="leading" secondItem="8gx-fm-mAn" secondAttribute="leading" id="Wpe-fa-Amj"/>
86+
<constraint firstAttribute="trailing" secondItem="h16-E5-l3y" secondAttribute="trailing" id="pTP-1p-kJy"/>
87+
</constraints>
88+
</tableViewCellContentView>
89+
<connections>
90+
<outlet property="contentViewLeftConstraint" destination="Wpe-fa-Amj" id="ARx-9a-yaJ"/>
91+
<outlet property="contentViewRightConstraint" destination="pTP-1p-kJy" id="Y3V-ZR-0bI"/>
92+
<outlet property="myContentView" destination="h16-E5-l3y" id="UHh-Qf-a5T"/>
93+
<outlet property="storyboardExampleLabel" destination="qMz-vv-1tY" id="c6i-v6-t9a"/>
94+
<outlet property="storyboardImageView" destination="ZBn-9o-dpV" id="UNR-Ye-RiX"/>
95+
</connections>
96+
</tableViewCell>
97+
</prototypes>
98+
<connections>
99+
<outlet property="dataSource" destination="e6f-rn-fWV" id="4q8-4f-lwg"/>
100+
<outlet property="delegate" destination="e6f-rn-fWV" id="amD-v3-rF4"/>
101+
</connections>
102+
</tableView>
103+
<navigationItem key="navigationItem" id="mHm-6f-WDm">
104+
<barButtonItem key="rightBarButtonItem" systemItem="done" id="gkW-Uc-YwF">
105+
<connections>
106+
<action selector="close:" destination="e6f-rn-fWV" id="TZ5-yX-wet"/>
107+
</connections>
108+
</barButtonItem>
109+
</navigationItem>
110+
</tableViewController>
111+
<placeholder placeholderIdentifier="IBFirstResponder" id="Vj9-vn-vZB" userLabel="First Responder" sceneMemberID="firstResponder"/>
112+
</objects>
113+
<point key="canvasLocation" x="620" y="821"/>
114+
</scene>
115+
<!--Master-->
23116
<scene sceneID="VgW-fR-Quf">
24117
<objects>
25118
<tableViewController title="Master" id="pGg-6v-bdr" customClass="MasterViewController" sceneMemberID="viewController">
@@ -33,13 +126,19 @@
33126
<outlet property="delegate" destination="pGg-6v-bdr" id="Y6K-Cp-Qkv"/>
34127
</connections>
35128
</tableView>
36-
<navigationItem key="navigationItem" title="Portraits of a Jerkface Kittah" id="tQt-TN-PWz"/>
129+
<navigationItem key="navigationItem" title="Portraits of a Jerkface Kittah" id="tQt-TN-PWz">
130+
<barButtonItem key="rightBarButtonItem" title="SB" id="Oif-1v-53q">
131+
<connections>
132+
<action selector="showStoryboardVC:" destination="pGg-6v-bdr" id="F8g-hq-zUT"/>
133+
</connections>
134+
</barButtonItem>
135+
</navigationItem>
37136
</tableViewController>
38137
<placeholder placeholderIdentifier="IBFirstResponder" id="6Cn-md-YlS" sceneMemberID="firstResponder"/>
39138
</objects>
40139
<point key="canvasLocation" x="459" y="64"/>
41140
</scene>
42-
<!--Detail View Controller - Detail-->
141+
<!--Detail-->
43142
<scene sceneID="Cn3-H9-jdl">
44143
<objects>
45144
<viewController storyboardIdentifier="DetailViewController" title="Detail" id="Ah7-4n-0Wa" customClass="DetailViewController" sceneMemberID="viewController">
@@ -59,8 +158,7 @@
59158
<nil key="highlightedColor"/>
60159
</label>
61160
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="P3O-DM-PAm">
62-
<rect key="frame" x="20" y="72" width="280" height="196"/>
63-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
161+
<rect key="frame" x="20" y="28" width="280" height="240"/>
64162
</imageView>
65163
</subviews>
66164
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
@@ -91,4 +189,4 @@
91189
<simulatedOrientationMetrics key="orientation"/>
92190
<simulatedScreenMetrics key="destination" type="retina4"/>
93191
</simulatedMetricsContainer>
94-
</document>
192+
</document>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// DNSStoryboardCell.h
3+
// DNSSwipeableCell
4+
//
5+
// Created by Ellen Shapiro on 2/26/15.
6+
// Copyright (c) 2015 Designated Nerd Software. All rights reserved.
7+
//
8+
9+
#import "DNSSwipeableCell.h"
10+
11+
@interface DNSStoryboardCell : DNSSwipeableCell
12+
13+
+ (NSString *)reuseIdentifier;
14+
+ (CGFloat)cellHeight;
15+
16+
@property (nonatomic, weak) IBOutlet UIImageView *storyboardImageView;
17+
@property (nonatomic, weak) IBOutlet UILabel *storyboardExampleLabel;
18+
19+
@end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// DNSStoryboardCell.m
3+
// DNSSwipeableCell
4+
//
5+
// Created by Ellen Shapiro on 2/26/15.
6+
// Copyright (c) 2015 Designated Nerd Software. All rights reserved.
7+
//
8+
9+
#import "DNSStoryboardCell.h"
10+
11+
@implementation DNSStoryboardCell
12+
13+
- (void)awakeFromNib
14+
{
15+
if (![[NSProcessInfo processInfo] respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)]) {
16+
//We're on iOS 7, and cells are dumb.
17+
[self.contentView setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
18+
}
19+
20+
[super awakeFromNib];
21+
}
22+
23+
+ (NSString *)reuseIdentifier
24+
{
25+
return NSStringFromClass(self);
26+
}
27+
28+
+ (CGFloat)cellHeight
29+
{
30+
return 400.0f;
31+
}
32+
33+
@end

0 commit comments

Comments
 (0)