Skip to content

Commit

Permalink
Adding a demo to swap controllers. Not working yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Inferis committed Dec 14, 2011
1 parent 7cccf63 commit 7311df4
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 24 deletions.
4 changes: 3 additions & 1 deletion ViewDeckExample/AppDelegate.h
Expand Up @@ -14,6 +14,8 @@

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) UIViewController *viewController;
@property (strong, nonatomic) UIViewController *centerController;
@property (strong, nonatomic) UIViewController *leftController;
@property (strong, nonatomic) UIViewController *imageController;

@end
15 changes: 8 additions & 7 deletions ViewDeckExample/AppDelegate.m
Expand Up @@ -16,25 +16,26 @@
@implementation AppDelegate

@synthesize window = _window;
@synthesize viewController = _viewController;
@synthesize centerController = _viewController;
@synthesize leftController = _leftController;
@synthesize imageController = _imageController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.

LeftViewController* leftController = [[LeftViewController alloc] initWithNibName:@"LeftViewController" bundle:nil];
self.leftController = [[LeftViewController alloc] initWithNibName:@"LeftViewController" bundle:nil];
RightViewController* rightController = [[RightViewController alloc] initWithNibName:@"RightViewController" bundle:nil];

ViewController* viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:viewController];
self.centerController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:self.centerController];
IIViewDeckController* deckController = [[IIViewDeckController alloc] initWithCenterViewController:navController
leftViewController:leftController
leftViewController:self.leftController
rightViewController:rightController];
deckController.rightLedge = 100;
self.viewController = deckController;

self.window.rootViewController = self.viewController;
self.window.rootViewController = deckController;
[self.window makeKeyAndVisible];
return YES;
}
Expand Down
4 changes: 4 additions & 0 deletions ViewDeckExample/RightViewController.h
Expand Up @@ -10,4 +10,8 @@

@interface RightViewController : UIViewController

- (IBAction)defaultCenterPressed:(id)sender;
- (IBAction)swapLeftAndCenterPressed:(id)sender;
- (IBAction)imageAsCenterPressed:(id)sender;

@end
31 changes: 18 additions & 13 deletions ViewDeckExample/RightViewController.m
Expand Up @@ -7,6 +7,9 @@
//

#import "RightViewController.h"
#import "LeftViewController.h"
#import "ViewController.h"
#import "IIViewDeckController.h"

@implementation RightViewController

Expand All @@ -29,23 +32,25 @@ - (void)didReceiveMemoryWarning

#pragma mark - View lifecycle

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
- (IBAction)defaultCenterPressed:(id)sender {
if (self.viewDeckController.centerController != SharedAppDelegate.centerController)
self.viewDeckController.centerController = SharedAppDelegate.centerController;

if (self.viewDeckController.leftController != SharedAppDelegate.leftController)
self.viewDeckController.leftController = SharedAppDelegate.leftController;
}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
- (IBAction)swapLeftAndCenterPressed:(id)sender {
if (self.viewDeckController.centerController != SharedAppDelegate.leftController)
self.viewDeckController.centerController = SharedAppDelegate.leftController;

if (self.viewDeckController.leftController != SharedAppDelegate.centerController)
self.viewDeckController.leftController = SharedAppDelegate.centerController;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
- (IBAction)imageAsCenterPressed:(id)sender {

}


@end
158 changes: 155 additions & 3 deletions ViewDeckExample/RightViewController.xib
Expand Up @@ -11,9 +11,10 @@
<string key="NS.object.0">933</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUIView</string>
<string>IBUIButton</string>
<string>IBUIImageView</string>
<string>IBUIView</string>
<string>IBProxyObject</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
Expand Down Expand Up @@ -41,6 +42,7 @@
<string key="NSFrameSize">{320, 460}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="691437836"/>
<string key="NSReuseIdentifierKey">_NS:567</string>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
Expand All @@ -49,10 +51,93 @@
<string key="NSResourceName">bg.jpg</string>
</object>
</object>
<object class="IBUIButton" id="691437836">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{127, 20}, {173, 92}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="827011900"/>
<string key="NSReuseIdentifierKey">_NS:225</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">Default Center</string>
<object class="NSColor" key="IBUIHighlightedTitleColor" id="496081773">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleShadowColor" id="49500627">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC41AA</bytes>
</object>
<object class="IBUIFontDescription" key="IBUIFontDescription" id="1033390871">
<int key="type">2</int>
<double key="pointSize">15</double>
</object>
<object class="NSFont" key="IBUIFont" id="833115814">
<string key="NSName">Helvetica-Bold</string>
<double key="NSSize">15</double>
<int key="NSfFlags">16</int>
</object>
</object>
<object class="IBUIButton" id="827011900">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{127, 120}, {173, 92}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="875385754"/>
<string key="NSReuseIdentifierKey">_NS:225</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">Swap Left &amp; Center</string>
<reference key="IBUIHighlightedTitleColor" ref="496081773"/>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
<reference key="IBUINormalTitleShadowColor" ref="49500627"/>
<reference key="IBUIFontDescription" ref="1033390871"/>
<reference key="IBUIFont" ref="833115814"/>
</object>
<object class="IBUIButton" id="875385754">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{127, 220}, {173, 92}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:225</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">Image Center</string>
<reference key="IBUIHighlightedTitleColor" ref="496081773"/>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
<reference key="IBUINormalTitleShadowColor" ref="49500627"/>
<reference key="IBUIFontDescription" ref="1033390871"/>
<reference key="IBUIFont" ref="833115814"/>
</object>
</array>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="765695467"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAwLjQzNTI5NDEyMTUgMC44MTE3NjQ3MTcxAA</bytes>
Expand All @@ -71,6 +156,33 @@
</object>
<int key="connectionID">3</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">defaultCenterPressed:</string>
<reference key="source" ref="691437836"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">8</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">swapLeftAndCenterPressed:</string>
<reference key="source" ref="827011900"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">9</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">imageAsCenterPressed:</string>
<reference key="source" ref="875385754"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">10</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
Expand All @@ -85,6 +197,9 @@
<reference key="object" ref="191373211"/>
<array class="NSMutableArray" key="children">
<reference ref="765695467"/>
<reference ref="691437836"/>
<reference ref="827011900"/>
<reference ref="875385754"/>
</array>
<reference key="parent" ref="0"/>
</object>
Expand All @@ -104,6 +219,21 @@
<reference key="object" ref="765695467"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">5</int>
<reference key="object" ref="691437836"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">6</int>
<reference key="object" ref="827011900"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">7</int>
<reference key="object" ref="875385754"/>
<reference key="parent" ref="191373211"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
Expand All @@ -113,18 +243,40 @@
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="7.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">4</int>
<int key="maxID">10</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">RightViewController</string>
<string key="superclassName">UIViewController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="defaultCenterPressed:">id</string>
<string key="imageAsCenterPressed:">id</string>
<string key="swapLeftAndCenterPressed:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="defaultCenterPressed:">
<string key="name">defaultCenterPressed:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="imageAsCenterPressed:">
<string key="name">imageAsCenterPressed:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="swapLeftAndCenterPressed:">
<string key="name">swapLeftAndCenterPressed:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/RightViewController.h</string>
Expand Down
4 changes: 4 additions & 0 deletions ViewDeckExample/ViewDeckExample-Prefix.pch
Expand Up @@ -11,4 +11,8 @@
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "AppDelegate.h"

#define SharedAppDelegate ((AppDelegate*)[[UIApplication sharedApplication] delegate])

#endif

0 comments on commit 7311df4

Please sign in to comment.