Permalink
Browse files

Added buttons to trigger left/right bounce.

Implemented bounce delegate methods in demo.
  • Loading branch information...
cbpowell committed Sep 9, 2012
1 parent f2af463 commit 716de9747f1ca99645992b4535d467df24d49070
Showing with 28 additions and 2 deletions.
  1. +18 −0 ViewDeckExample/RightViewController.m
  2. +10 −2 ViewDeckExample/ViewController.m
@@ -113,6 +113,15 @@ - (void)viewDeckController:(IIViewDeckController*)viewDeckController didPanToOff
[self addLog:[NSString stringWithFormat:@"Pan: %f", offset]];
}
+- (BOOL)viewDeckControllerWillBounceLeftView:(IIViewDeckController *)viewDeckController animated:(BOOL)animated {
+ [self addLog:@"will bounce left view"];
+ return YES;
+}
+
+- (void)viewDeckControllerDidBounceLeftView:(IIViewDeckController *)viewDeckController animated:(BOOL)animated {
+ [self addLog:@"did bounce left view"];
+}
+
- (BOOL)viewDeckControllerWillOpenLeftView:(IIViewDeckController*)viewDeckController animated:(BOOL)animated {
[self addLog:@"will open left view"];
return YES;
@@ -131,6 +140,15 @@ - (void)viewDeckControllerDidCloseLeftView:(IIViewDeckController*)viewDeckContro
[self addLog:@"did close left view"];
}
+- (BOOL)viewDeckControllerWillBounceRightView:(IIViewDeckController *)viewDeckController animated:(BOOL)animated {
+ [self addLog:@"will bounce right view"];
+ return YES;
+}
+
+- (void)viewDeckControllerDidBounceRightView:(IIViewDeckController *)viewDeckController animated:(BOOL)animated {
+ [self addLog:@"did bounce right view"];
+}
+
- (BOOL)viewDeckControllerWillOpenRightView:(IIViewDeckController*)viewDeckController animated:(BOOL)animated {
[self addLog:@"will open right view"];
return YES;
@@ -36,12 +36,20 @@ - (void)didReceiveMemoryWarning
- (void)viewDidLoad
{
[super viewDidLoad];
-
- self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"left" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleLeftView)];
+
+ if ([self.navigationItem respondsToSelector:@selector(leftBarButtonItems)]) {
+ self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:
+ [[UIBarButtonItem alloc] initWithTitle:@"left" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleLeftView)],
+ [[UIBarButtonItem alloc] initWithTitle:@"bounce" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(bounceLeftView)],
+ nil];
+ } else {
+ self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"left" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleLeftView)];
+ }
if ([self.navigationItem respondsToSelector:@selector(rightBarButtonItems)]) {
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc] initWithTitle:@"right" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)],
+ [[UIBarButtonItem alloc] initWithTitle:@"bounce" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(bounceRightView)],
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(showCam:)],
nil];
}

0 comments on commit 716de97

Please sign in to comment.