Permalink
Browse files

Fixed bug where the wrong view was restored when tapping or sliding t…

…he slid-over view.
  • Loading branch information...
ktatroe committed Jun 26, 2012
1 parent cee6984 commit 9b24a5e2b63173f5d1c99458915c981a278d8f30
@@ -140,48 +140,41 @@ - (void) singleTapScreenShot:(UITapGestureRecognizer*)gestureRecognizer
// and call the slideThenHide function
[self slideThenHide];
if (YES)
{
if ([appDelegate.contentViewController isKindOfClass:[PanelAViewController class]]) {
[self performSegueWithIdentifier:@"toPanelA" sender:self];
}
else
{
else {
[self performSegueWithIdentifier:@"toPanelB" sender:self];
}
}
- (void) panGestureMoveAround:(UIPanGestureRecognizer*)gesture;
{
UIView* piece = [gesture view];
[self adjustAnchorPointForGestureRecognizer:gesture];
if ([gesture state] == UIGestureRecognizerStateBegan || [gesture state] == UIGestureRecognizerStateChanged)
{
if ([gesture state] == UIGestureRecognizerStateBegan || [gesture state] == UIGestureRecognizerStateChanged) {
CGPoint translation = [gesture translationInView:[piece superview]];
[piece setCenter:CGPointMake([piece center].x + translation.x, [piece center].y)];
[gesture setTranslation:CGPointZero inView:[piece superview]];
}
else if ([gesture state] == UIGestureRecognizerStateEnded)
{
else if ([gesture state] == UIGestureRecognizerStateEnded) {
[self slideThenHide];
if (YES)
{
if ([appDelegate.contentViewController isKindOfClass:[PanelAViewController class]]) {
[self performSegueWithIdentifier:@"toPanelA" sender:self];
}
else
{
else {
[self performSegueWithIdentifier:@"toPanelB" sender:self];
}
}
}
- (void) adjustAnchorPointForGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateBegan)
{
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
UIView *piece = gestureRecognizer.view;
CGPoint locationInView = [gestureRecognizer locationInView:piece];
CGPoint locationInSuperview = [gestureRecognizer locationInView:piece.superview];
@@ -221,25 +214,23 @@ - (float) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPat
- (UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
static NSString* sContentTypeCellIdentifier = @"ContentTypeTableCell";
NSArray* titles = [NSArray arrayWithObjects:@"Panel A", @"Panel B", nil];
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:sContentTypeCellIdentifier];
NSArray* titles = [NSArray arrayWithObjects:@"Panel A", @"Panel B", nil];
cell.textLabel.text = NSLocalizedString([titles objectAtIndex:indexPath.row], nil);
return cell;
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- (void) tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
[self.contentTableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row == CONTENT_TYPE_PANEL_A_INDEX)
{
if (indexPath.row == CONTENT_TYPE_PANEL_A_INDEX) {
[self showPanelAViewController];
}
else if (indexPath.row == CONTENT_TYPE_PANEL_B_INDEX)
{
else if (indexPath.row == CONTENT_TYPE_PANEL_B_INDEX) {
[self showPanelBViewController];
}
}
@@ -8,9 +8,6 @@
#import "PanelAViewController.h"
@interface PanelAViewController ()
@end
@implementation PanelAViewController
@@ -8,9 +8,6 @@
#import "PanelBViewController.h"
@interface PanelBViewController ()
@end
@implementation PanelBViewController
@@ -18,63 +18,53 @@ @implementation SidePanelAppDelegate
@synthesize contentViewController;
@synthesize menuViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
self.menuViewController = [storyboard instantiateViewControllerWithIdentifier:@"menuViewController"];
// Override point for customization after application launch.
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
- (void) applicationWillResignActive:(UIApplication*)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
- (void) applicationDidEnterBackground:(UIApplication*)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
- (void) applicationWillEnterForeground:(UIApplication*)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
- (void) applicationDidBecomeActive:(UIApplication*)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
- (void) applicationWillTerminate:(UIApplication*)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
-(void) showSideMenu
- (void) showSideMenu
{
// before swaping the views, we'll take a "screenshot" of the current view
// by rendering its CALayer into the an ImageContext then saving that off to a UIImage
// generate an image from the current view
UIView* targetView = self.contentViewController.navigationController.view;
CGSize viewSize = targetView.bounds.size;
UIGraphicsBeginImageContextWithOptions(viewSize, NO, 0.0);
[targetView.layer renderInContext:UIGraphicsGetCurrentContext()];
// Read the UIImage object
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// pass this image off to the MenuViewController then swap it in as the rootViewController
// pass this image off to the MenuViewController, then swap it in as the rootViewController
self.menuViewController.screenShotImage = image;
self.window.rootViewController = self.menuViewController;
}
-(void) hideSideMenu
- (void) hideSideMenu
{
// all animation takes place elsewhere. When this gets called just swap the contentViewController in
// the actual animation is done by the MenuViewController
self.window.rootViewController = self.contentViewController;
}
@@ -8,6 +8,7 @@
#import <UIKit/UIKit.h>
@interface SlideoutStoryboardSegue : UIStoryboardSegue
@end
@@ -8,6 +8,7 @@
#import "SlideoutStoryboardSegue.h"
@implementation SlideoutStoryboardSegue
- (void) perform
View
@@ -7,9 +7,9 @@
//
#import <UIKit/UIKit.h>
#import "SidePanelAppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {

0 comments on commit 9b24a5e

Please sign in to comment.