Permalink
Browse files

Storyboard - Back Button

 Illustratrating a paging back feature on the view controllers
  • Loading branch information...
1 parent e7ca9c6 commit f385277a892bd89ade12b4b4f46b3ad42c0efd24 @burtlo burtlo committed Mar 27, 2012
@@ -10,7 +10,12 @@
@interface PSViewController : UIViewController
+@property (nonatomic,assign) BOOL showBackButton;
+@property (weak, nonatomic) IBOutlet UIButton *backButton;
+
- (IBAction)addRedViewController:(id)sender;
- (IBAction)addGreenViewController:(id)sender;
- (IBAction)addBlueViewController:(id)sender;
+
+- (IBAction)goBack:(id)sender;
@end
@@ -15,15 +15,34 @@ @interface PSViewController ()
@implementation PSViewController
+@synthesize showBackButton;
+@synthesize backButton;
+
+#pragma mark - View Lifecycle
+
+- (void)viewDidAppear:(BOOL)animated {
+ [super viewDidAppear:animated];
+ if (showBackButton) {
+ [[self backButton] setHidden:![self showBackButton]];
+ }
+
+}
+- (void)viewDidUnload {
+ [self setBackButton:nil];
+ [super viewDidUnload];
+}
+
+
+#pragma mark - Actions
+
- (void)pushViewControllerWithColor:(UIColor *)color {
PSViewController *viewController = [[PSViewController alloc] init];
[[viewController view] setBackgroundColor:color];
+ [viewController setShowBackButton:YES];
[[self stackController] pushViewController:viewController animated:YES];
- [[self stackController] setLeftInset:50];
-// [[self stackController] pushViewController:viewController fromViewController:self animated:YES];
}
@@ -39,4 +58,9 @@ - (IBAction)addBlueViewController:(id)sender {
[self pushViewControllerWithColor:[UIColor blueColor]];
}
+- (IBAction)goBack:(id)sender {
+
+ [[self stackController] expandStack:1 animated:YES];
+}
+
@end
@@ -70,7 +70,7 @@
<object class="IBUIButton" id="24596954">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{20, 20}, {52, 52}}</string>
+ <string key="NSFrame">{{14, 144}, {52, 52}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="736917191"/>
@@ -106,7 +106,7 @@
<object class="IBUIButton" id="736917191">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{20, 80}, {52, 52}}</string>
+ <string key="NSFrame">{{14, 204}, {52, 52}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1022037234"/>
@@ -129,10 +129,10 @@
<object class="IBUIButton" id="1022037234">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{20, 140}, {52, 52}}</string>
+ <string key="NSFrame">{{14, 264}, {52, 52}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="634465904"/>
+ <reference key="NSNextKeyView" ref="839202823"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -149,6 +149,29 @@
<reference key="IBUIFontDescription" ref="291747633"/>
<reference key="IBUIFont" ref="423807281"/>
</object>
+ <object class="IBUIButton" id="839202823">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">-2147483356</int>
+ <string key="NSFrame">{{14, 18}, {71, 52}}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="634465904"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <int key="IBUIButtonType">1</int>
+ <string key="IBUINormalTitle">Back</string>
+ <reference key="IBUIHighlightedTitleColor" ref="275580993"/>
+ <object class="NSColor" key="IBUINormalTitleColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+ </object>
+ <reference key="IBUINormalTitleShadowColor" ref="993176512"/>
+ <reference key="IBUIFontDescription" ref="291747633"/>
+ <reference key="IBUIFont" ref="423807281"/>
+ </object>
</array>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<reference key="NSSuperview"/>
@@ -176,6 +199,14 @@
<int key="connectionID">4</int>
</object>
<object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">backButton</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="839202823"/>
+ </object>
+ <int key="connectionID">15</int>
+ </object>
+ <object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">addRedViewController:</string>
<reference key="source" ref="24596954"/>
@@ -202,6 +233,15 @@
</object>
<int key="connectionID">10</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">goBack:</string>
+ <reference key="source" ref="839202823"/>
+ <reference key="destination" ref="372490531"/>
+ <int key="IBEventType">7</int>
+ </object>
+ <int key="connectionID">14</int>
+ </object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@@ -216,9 +256,10 @@
<reference key="object" ref="191373211"/>
<array class="NSMutableArray" key="children">
<reference ref="634465904"/>
+ <reference ref="24596954"/>
<reference ref="736917191"/>
<reference ref="1022037234"/>
- <reference ref="24596954"/>
+ <reference ref="839202823"/>
</array>
<reference key="parent" ref="0"/>
</object>
@@ -253,6 +294,11 @@
<reference key="object" ref="1022037234"/>
<reference key="parent" ref="191373211"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">11</int>
+ <reference key="object" ref="839202823"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -261,6 +307,7 @@
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="11.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="3.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -270,7 +317,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">10</int>
+ <int key="maxID">15</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -281,6 +328,7 @@
<string key="addBlueViewController:">id</string>
<string key="addGreenViewController:">id</string>
<string key="addRedViewController:">id</string>
+ <string key="goBack:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="addBlueViewController:">
@@ -295,7 +343,22 @@
<string key="name">addRedViewController:</string>
<string key="candidateClassName">id</string>
</object>
+ <object class="IBActionInfo" key="goBack:">
+ <string key="name">goBack:</string>
+ <string key="candidateClassName">id</string>
+ </object>
</dictionary>
+ <object class="NSMutableDictionary" key="outlets">
+ <string key="NS.key.0">backButton</string>
+ <string key="NS.object.0">UIButton</string>
+ </object>
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <string key="NS.key.0">backButton</string>
+ <object class="IBToOneOutletInfo" key="NS.object.0">
+ <string key="name">backButton</string>
+ <string key="candidateClassName">UIButton</string>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/PSViewController.h</string>
@@ -11,6 +11,14 @@
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="4" sceneMemberID="firstResponder"/>
<viewController id="2" customClass="PSStackedViewController" sceneMemberID="viewController">
+ <userDefinedRuntimeAttributes>
+ <userDefinedRuntimeAttribute type="number" keyPath="leftInset">
+ <real key="value" value="0.0"/>
+ </userDefinedRuntimeAttribute>
+ <userDefinedRuntimeAttribute type="number" keyPath="largeLeftInset">
+ <real key="value" value="320"/>
+ </userDefinedRuntimeAttribute>
+ </userDefinedRuntimeAttributes>
<connections>
<outlet property="rootViewController" destination="hla-rk-vUF" id="UIv-3W-oQV"/>
</connections>
@@ -28,6 +36,11 @@
</class>
<class className="PSViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/PSViewController.h"/>
+ <relationships>
+ <relationship kind="action" name="addBlueViewController:"/>
+ <relationship kind="action" name="addGreenViewController:"/>
+ <relationship kind="action" name="addRedViewController:"/>
+ </relationships>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">

0 comments on commit f385277

Please sign in to comment.