Skip to content

Commit c8240bb

Browse files
committed
Add UINavigationController example.
1 parent 2ca6d98 commit c8240bb

File tree

8 files changed

+271
-3
lines changed

8 files changed

+271
-3
lines changed

ECSlidingViewController.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
/* Begin PBXBuildFile section */
1010
27407EEC14D8787E0035FD7F /* iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 27407EEB14D8787E0035FD7F /* iPad.storyboard */; };
11+
27498DCE14E96C75005C043E /* NavigationTopViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 27498DCD14E96C75005C043E /* NavigationTopViewController.m */; };
12+
27498DD514E96EEF005C043E /* SampleTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 27498DD414E96EEF005C043E /* SampleTableViewController.m */; };
1113
2750E77114CDB0DF007727A0 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2750E77014CDB0DF007727A0 /* UIKit.framework */; };
1214
2750E77314CDB0DF007727A0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2750E77214CDB0DF007727A0 /* Foundation.framework */; };
1315
2750E77514CDB0DF007727A0 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2750E77414CDB0DF007727A0 /* CoreGraphics.framework */; };
@@ -28,6 +30,10 @@
2830

2931
/* Begin PBXFileReference section */
3032
27407EEB14D8787E0035FD7F /* iPad.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = iPad.storyboard; sourceTree = "<group>"; };
33+
27498DCC14E96C75005C043E /* NavigationTopViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationTopViewController.h; sourceTree = "<group>"; };
34+
27498DCD14E96C75005C043E /* NavigationTopViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavigationTopViewController.m; sourceTree = "<group>"; };
35+
27498DD314E96EEF005C043E /* SampleTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SampleTableViewController.h; sourceTree = "<group>"; };
36+
27498DD414E96EEF005C043E /* SampleTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SampleTableViewController.m; sourceTree = "<group>"; };
3137
2750E76C14CDB0DF007727A0 /* ECSlidingViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ECSlidingViewController.app; sourceTree = BUILT_PRODUCTS_DIR; };
3238
2750E77014CDB0DF007727A0 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
3339
2750E77214CDB0DF007727A0 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -143,6 +149,10 @@
143149
27FC94DF14D0C14E0000B18C /* InitialSlidingViewController.m */,
144150
2750E79214CDB93A007727A0 /* MenuViewController.h */,
145151
2750E79314CDB93A007727A0 /* MenuViewController.m */,
152+
27498DCC14E96C75005C043E /* NavigationTopViewController.h */,
153+
27498DCD14E96C75005C043E /* NavigationTopViewController.m */,
154+
27498DD314E96EEF005C043E /* SampleTableViewController.h */,
155+
27498DD414E96EEF005C043E /* SampleTableViewController.m */,
146156
2750E79814CDB99A007727A0 /* SecondTopViewController.h */,
147157
2750E79914CDB99A007727A0 /* SecondTopViewController.m */,
148158
2750E79B14CDBA48007727A0 /* ThirdTopViewController.h */,
@@ -238,6 +248,8 @@
238248
2750E7AE14CF1306007727A0 /* ECSlidingViewController.m in Sources */,
239249
2750E7AF14CF1306007727A0 /* UIImage+ImageWithUIView.m in Sources */,
240250
27FC94E014D0C14E0000B18C /* InitialSlidingViewController.m in Sources */,
251+
27498DCE14E96C75005C043E /* NavigationTopViewController.m in Sources */,
252+
27498DD514E96EEF005C043E /* SampleTableViewController.m in Sources */,
241253
);
242254
runOnlyForDeploymentPostprocessing = 0;
243255
};

ECSlidingViewController/MenuViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ @implementation MenuViewController
1717

1818
- (void)awakeFromNib
1919
{
20-
self.menuItems = [NSArray arrayWithObjects:@"First", @"Second", @"Third", nil];
20+
self.menuItems = [NSArray arrayWithObjects:@"First", @"Second", @"Third", @"Navigation", nil];
2121
}
2222

2323
- (void)viewDidLoad
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// NavigationTopViewController.h
3+
// ECSlidingViewController
4+
//
5+
// Created by Michael Enriquez on 2/13/12.
6+
// Copyright (c) 2012 EdgeCase. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
#import "ECSlidingViewController.h"
11+
#import "MenuViewController.h"
12+
#import "UnderRightViewController.h"
13+
14+
@interface NavigationTopViewController : UINavigationController
15+
16+
@end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// NavigationTopViewController.m
3+
// ECSlidingViewController
4+
//
5+
// Created by Michael Enriquez on 2/13/12.
6+
// Copyright (c) 2012 EdgeCase. All rights reserved.
7+
//
8+
9+
#import "NavigationTopViewController.h"
10+
11+
@implementation NavigationTopViewController
12+
13+
- (void)viewWillAppear:(BOOL)animated
14+
{
15+
[super viewWillAppear:animated];
16+
17+
UIStoryboard *storyboard;
18+
19+
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
20+
storyboard = [UIStoryboard storyboardWithName:@"iPhone" bundle:nil];
21+
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
22+
storyboard = [UIStoryboard storyboardWithName:@"iPad" bundle:nil];
23+
}
24+
25+
if (![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
26+
self.slidingViewController.underLeftViewController = [storyboard instantiateViewControllerWithIdentifier:@"Menu"];
27+
}
28+
29+
if (![self.slidingViewController.underRightViewController isKindOfClass:[UnderRightViewController class]]) {
30+
self.slidingViewController.underRightViewController = [storyboard instantiateViewControllerWithIdentifier:@"UnderRight"];
31+
}
32+
33+
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
34+
}
35+
36+
@end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// SampleTableViewController.h
3+
// ECSlidingViewController
4+
//
5+
// Created by Michael Enriquez on 2/13/12.
6+
// Copyright (c) 2012 EdgeCase. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
#import "ECSlidingViewController.h"
11+
12+
@interface SampleTableViewController : UITableViewController <UITableViewDataSource, UITabBarControllerDelegate>
13+
- (IBAction)revealMenu:(id)sender;
14+
@end
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// SampleTableViewController.m
3+
// ECSlidingViewController
4+
//
5+
// Created by Michael Enriquez on 2/13/12.
6+
// Copyright (c) 2012 EdgeCase. All rights reserved.
7+
//
8+
9+
#import "SampleTableViewController.h"
10+
11+
@interface SampleTableViewController()
12+
@property (nonatomic, strong) NSArray *sampleItems;
13+
@end
14+
15+
@implementation SampleTableViewController
16+
@synthesize sampleItems;
17+
18+
- (void)awakeFromNib
19+
{
20+
self.sampleItems = [NSArray arrayWithObjects:@"One", @"Two", @"Three", nil];
21+
}
22+
23+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex
24+
{
25+
return self.sampleItems.count;
26+
}
27+
28+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
29+
{
30+
NSString *cellIdentifier = @"SampleCell";
31+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
32+
if (cell == nil) {
33+
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
34+
}
35+
36+
cell.textLabel.text = [self.sampleItems objectAtIndex:indexPath.row];
37+
38+
return cell;
39+
}
40+
41+
- (IBAction)revealMenu:(id)sender
42+
{
43+
[self.slidingViewController anchorTopViewTo:ECRight animations:nil onComplete:nil];
44+
}
45+
46+
@end

ECSlidingViewController/iPad.storyboard

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.0" toolsVersion="1938" systemVersion="11C74" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="SIb-O2-Xa4">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.0" toolsVersion="1938" systemVersion="11D50" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="SIb-O2-Xa4">
33
<dependencies>
44
<development defaultVersion="4200" identifier="xcode"/>
55
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="933"/>
@@ -85,6 +85,66 @@
8585
</objects>
8686
<point key="canvasLocation" x="1366" y="-3472"/>
8787
</scene>
88+
<scene sceneID="9Lf-Ds-7hE">
89+
<objects>
90+
<placeholder placeholderIdentifier="IBFirstResponder" id="iCA-AT-FmW" userLabel="First Responder" sceneMemberID="firstResponder"/>
91+
<viewController id="7TO-m0-aL5" sceneMemberID="viewController">
92+
<view key="view" contentMode="scaleToFill" id="Wly-m0-fDF">
93+
<rect key="frame" x="0.0" y="64" width="768" height="960"/>
94+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
95+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
96+
</view>
97+
<navigationItem key="navigationItem" id="voj-fx-Y0v"/>
98+
</viewController>
99+
</objects>
100+
<point key="canvasLocation" x="3128" y="-4635"/>
101+
</scene>
102+
<scene sceneID="uTs-LF-eUf">
103+
<objects>
104+
<placeholder placeholderIdentifier="IBFirstResponder" id="Mkw-MZ-h1g" userLabel="First Responder" sceneMemberID="firstResponder"/>
105+
<navigationController storyboardIdentifier="NavigationTop" definesPresentationContext="YES" id="1hx-oA-DgE" customClass="NavigationTopViewController" sceneMemberID="viewController">
106+
<navigationBar key="navigationBar" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="vlA-OI-a5q">
107+
<autoresizingMask key="autoresizingMask"/>
108+
</navigationBar>
109+
<connections>
110+
<segue destination="NXj-9U-Y8g" kind="relationship" relationship="rootViewController" id="bjU-iw-BID"/>
111+
</connections>
112+
</navigationController>
113+
</objects>
114+
<point key="canvasLocation" x="1366" y="-4635"/>
115+
</scene>
116+
<scene sceneID="ZSn-tl-r3h">
117+
<objects>
118+
<placeholder placeholderIdentifier="IBFirstResponder" id="0q0-M8-OFj" userLabel="First Responder" sceneMemberID="firstResponder"/>
119+
<tableViewController id="NXj-9U-Y8g" customClass="SampleTableViewController" sceneMemberID="viewController">
120+
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="kNR-UP-LbH">
121+
<rect key="frame" x="0.0" y="64" width="768" height="960"/>
122+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
123+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
124+
<prototypes>
125+
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="SampleCell" id="tZ1-2i-beG">
126+
<rect key="frame" x="0.0" y="22" width="768" height="44"/>
127+
<autoresizingMask key="autoresizingMask"/>
128+
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
129+
<rect key="frame" x="0.0" y="0.0" width="748" height="43"/>
130+
<autoresizingMask key="autoresizingMask"/>
131+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
132+
</view>
133+
<connections>
134+
<segue destination="7TO-m0-aL5" kind="push" id="jdF-xA-4Z1"/>
135+
</connections>
136+
</tableViewCell>
137+
</prototypes>
138+
<connections>
139+
<outlet property="dataSource" destination="NXj-9U-Y8g" id="cYZ-fh-wB2"/>
140+
<outlet property="delegate" destination="NXj-9U-Y8g" id="3LL-BN-9x0"/>
141+
</connections>
142+
</tableView>
143+
<navigationItem key="navigationItem" id="wWQ-ug-3ai"/>
144+
</tableViewController>
145+
</objects>
146+
<point key="canvasLocation" x="2228" y="-4635"/>
147+
</scene>
88148
<scene sceneID="krM-pN-5xZ">
89149
<objects>
90150
<placeholder placeholderIdentifier="IBFirstResponder" id="sXC-W5-s9Y" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -197,6 +257,15 @@
197257
<class className="MenuViewController" superclassName="UIViewController">
198258
<source key="sourceIdentifier" type="project" relativePath="./Classes/MenuViewController.h"/>
199259
</class>
260+
<class className="NavigationTopViewController" superclassName="UINavigationController">
261+
<source key="sourceIdentifier" type="project" relativePath="./Classes/NavigationTopViewController.h"/>
262+
</class>
263+
<class className="SampleTableViewController" superclassName="UITableViewController">
264+
<source key="sourceIdentifier" type="project" relativePath="./Classes/SampleTableViewController.h"/>
265+
<relationships>
266+
<relationship kind="action" name="revealMenu:"/>
267+
</relationships>
268+
</class>
200269
<class className="SecondTopViewController" superclassName="UIViewController">
201270
<source key="sourceIdentifier" type="project" relativePath="./Classes/SecondTopViewController.h"/>
202271
<relationships>

0 commit comments

Comments
 (0)