Permalink
Browse files

Flip Storyboard segue classes

  • Loading branch information...
1 parent 97bc1a0 commit 04c1d8ea028e7c40ea3375ed8dc5e5a6f8d16086 Mark Pospesel committed May 16, 2012
@@ -13,6 +13,7 @@
4DB9BF1F1553E36200718F74 /* Icon-72@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4DB9BF1B1553E36200718F74 /* Icon-72@2x.png */; };
4DB9BF201553E36200718F74 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 4DB9BF1C1553E36200718F74 /* Icon.png */; };
4DB9BF211553E36200718F74 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4DB9BF1D1553E36200718F74 /* Icon@2x.png */; };
+ 4DBA43C515639EA800D02824 /* MPFlipSegue.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DBA43C015639C5100D02824 /* MPFlipSegue.m */; };
4DBDFA0915415F0A003AD415 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DBDFA0815415F0A003AD415 /* UIKit.framework */; };
4DBDFA0B15415F0A003AD415 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DBDFA0A15415F0A003AD415 /* Foundation.framework */; };
4DBDFA0D15415F0A003AD415 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DBDFA0C15415F0A003AD415 /* CoreGraphics.framework */; };
@@ -51,6 +52,8 @@
4DB9BF221553E3A300718F74 /* Source Code License.rtf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.rtf; path = "Source Code License.rtf"; sourceTree = "<group>"; };
4DB9BF241553EA8A00718F74 /* README.markdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.markdown; sourceTree = "<group>"; };
4DB9BF251553EA8A00718F74 /* TODO.markdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TODO.markdown; sourceTree = "<group>"; };
+ 4DBA43BF15639C5100D02824 /* MPFlipSegue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPFlipSegue.h; sourceTree = "<group>"; };
+ 4DBA43C015639C5100D02824 /* MPFlipSegue.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPFlipSegue.m; sourceTree = "<group>"; };
4DBDFA0415415F0A003AD415 /* MPFoldTransition.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MPFoldTransition.app; sourceTree = BUILT_PRODUCTS_DIR; };
4DBDFA0815415F0A003AD415 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
4DBDFA0A15415F0A003AD415 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -110,6 +113,8 @@
4DBDFA3715416BAD003AD415 /* MPFoldNavPopSegue.m */,
4DBDFA3815416BAD003AD415 /* MPFoldNavPushSegue.h */,
4DBDFA3915416BAD003AD415 /* MPFoldNavPushSegue.m */,
+ 4DBA43BF15639C5100D02824 /* MPFlipSegue.h */,
+ 4DBA43C015639C5100D02824 /* MPFlipSegue.m */,
);
path = Segues;
sourceTree = "<group>";
@@ -292,6 +297,7 @@
4DFA2F11154FF4A1004AF678 /* DetailsViewController.m in Sources */,
4DB921531561117B0080D608 /* MPTransition.m in Sources */,
4DEBF71A1562587100553D98 /* MPFlipTransition.m in Sources */,
+ 4DBA43C515639EA800D02824 /* MPFlipSegue.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -0,0 +1,36 @@
+//
+// MPFlipSegue.h
+// MPTransition (v 1.1.0)
+//
+// Created by Mark Pospesel on 4/18/12.
+// Copyright (c) 2012 Mark Pospesel. All rights reserved.
+//
+
+// You must subclass this class, it performs no segue on its own
+
+#import <UIKit/UIKit.h>
+#import "MPFlipEnumerations.h"
+
+#pragma mark - superclass
+
+@interface MPFlipSegue : UIStoryboardSegue
+
+@property (assign, nonatomic) MPFlipStyle style;
+
+- (void)perform;
Aristotong
Aristotong Jun 1, 2015
  • (void)presentViewController:(UIViewController *)viewControllerToPresent
    foldStyle:(MPFoldStyle)style
    completion:(void (^)(BOOL finished))completion;
  • (void)dismissViewControllerWithFoldStyle:(MPFoldStyle)style
    completion:(void (^)(BOOL finished))completion;
+
+@end
+
+#pragma mark - subclasses
+
+@interface MPFlipModalSegue : MPFlipSegue
+
+@end
+
+@interface MPFlipNavPushSegue : MPFlipSegue
+
+@end
+
+@interface MPFlipNavPopSegue : MPFlipSegue
+
+@end
@@ -0,0 +1,107 @@
+//
+// MPFlipSegue.m
+// MPTransition (v 1.1.0)
+//
+// Created by Mark Pospesel on 4/18/12.
+// Copyright (c) 2012 Mark Pospesel. All rights reserved.
+//
+
+#import "MPFlipSegue.h"
+#import "MPFlipTransition.h"
+
+#pragma mark - superclass
+
+@implementation MPFlipSegue
+
+@synthesize style = _style;
+
+- (id)init
+{
+ self = [super init];
+ if (self)
+ {
+ [self doInit];
+ }
+
+ return self;
+}
+
+- (id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination
+{
+ self = [super initWithIdentifier:identifier source:source destination:destination];
+ if (self)
+ {
+ [self doInit];
+ }
+
+ return self;
+}
+
+- (void)doInit
+{
+ _style = [self defaultStyle];
+}
+
+- (MPFlipStyle)defaultStyle
+{
+ return MPFlipStyleDefault;
+}
+
+- (void)perform
+{
+ [NSException raise:@"Incomplete Implementation" format:@"MPFlipSegue must be subclassed and the perform method implemented."];
+}
+
+@end
+
+#pragma mark - subclasses
+
+@implementation MPFlipModalSegue
+
+- (void)perform
+{
+ [self.sourceViewController presentViewController:self.destinationViewController flipStyle:[self style] completion:nil];
+}
+
+@end
+
+@implementation MPFlipNavPushSegue
+
+- (void)perform
+{
+ UIViewController *src = (UIViewController *) self.sourceViewController;
+ UIViewController *dest = (UIViewController *) self.destinationViewController;
+ UINavigationController *navController = src.navigationController;
+ if (!navController)
+ [NSException raise:@"Invalid Operation" format:@"MPFlipNavPopSegue can only be performed on a child controller of a UINavigationController."];
+
+ if (![[navController visibleViewController] isEqual:src])
+ [NSException raise:@"Invalid Operation" format:@"MPFlipNavPopSegue can only be performed from the current visibleViewController of a UINavigationController."];
+
+ [navController pushViewController:dest flipStyle:[self style]];
+}
+
+@end
+
+@implementation MPFlipNavPopSegue
+
+- (MPFlipStyle)defaultStyle
+{
+ return MPFlipStyleDirectionBackward;
+}
+
+- (void)perform
+{
+ UIViewController *src = (UIViewController *) self.sourceViewController;
+ UINavigationController *navController = src.navigationController;
+ if (!navController)
+ [NSException raise:@"Invalid Operation" format:@"MPFlipNavPopSegue can only be performed on a child controller of a UINavigationController."];
+ if (![[navController visibleViewController] isEqual:src])
+ [NSException raise:@"Invalid Operation" format:@"MPFlipNavPopSegue can only be performed from the current visibleViewController of a UINavigationController."];
+ if ([navController.viewControllers count] < 2)
+ [NSException raise:@"Invalid Operation" format:@"UINavigationController parent must have at least 2 child controllers in its stack. Otherwise no pop can be performed."];
+
+ [navController popViewControllerWithFlipStyle:[self style]];
+}
+
+@end

0 comments on commit 04c1d8e

Please sign in to comment.