Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Working on proxies for pre ios5 view containment.

  • Loading branch information...
commit 00e7079b5baf1c73c46dc6b1bff4c2ef3972d6ff 1 parent 6a281c1
@Inferis Inferis authored
Showing with 37 additions and 18 deletions.
  1. +37 −18 ViewDeck/IIViewDeckController.m
View
55 ViewDeck/IIViewDeckController.m
@@ -151,8 +151,6 @@ - (void)setViewDeckController:(IIViewDeckController*)viewDeckController;
@end
-#ifndef __IPHONE_5_0
-
@interface UIViewController (UIViewDeckController_ViewContainmentEmulation)
- (void)addChildViewController:(UIViewController *)childController;
@@ -162,8 +160,6 @@ - (void)didMoveToParentViewController:(UIViewController *)parent;
@end
-#endif
-
@implementation IIViewDeckController
@@ -834,10 +830,10 @@ - (void)closeRightViewBouncing:(void(^)(IIViewDeckController* controller))bounce
#pragma mark - Pre iOS5 message relaying
- (void)relayAppearanceMethod:(void(^)(UIViewController* controller))relay {
- bool shouldRelay = ![self respondsToSelector:@selector(automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers)] && ![self performSelector:@selector(automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers)];
+ bool shouldRelay = ![self respondsToSelector:@selector(automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers)] || ![self performSelector:@selector(automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers)];
// don't relay if the controller supports automatic relaying
- if (shouldRelay)
+ if (!shouldRelay)
return;
relay(self.centerController);
@@ -1420,7 +1416,6 @@ + (void)vdc_swizzle {
SEL vdcDismissModal = @selector(vdc_dismissModalViewControllerAnimated:);
method_exchangeImplementations(class_getInstanceMethod(self, dismissModal), class_getInstanceMethod(self, vdcDismissModal));
-#ifdef __IPHONE_5_0
SEL presentVC = @selector(presentViewController:animated:completion:);
SEL vdcPresentVC = @selector(vdc_presentViewController:animated:completion:);
method_exchangeImplementations(class_getInstanceMethod(self, presentVC), class_getInstanceMethod(self, vdcPresentVC));
@@ -1428,7 +1423,6 @@ + (void)vdc_swizzle {
SEL dismissVC = @selector(dismissViewControllerAnimated:completion:);
SEL vdcDismissVC = @selector(vdc_dismissViewControllerAnimated:completion:);
method_exchangeImplementations(class_getInstanceMethod(self, dismissVC), class_getInstanceMethod(self, vdcDismissVC));
-#endif
SEL nc = @selector(navigationController);
SEL vdcnc = @selector(vdc_navigationController);
@@ -1437,6 +1431,35 @@ + (void)vdc_swizzle {
SEL ni = @selector(navigationItem);
SEL vdcni = @selector(vdc_navigationItem);
method_exchangeImplementations(class_getInstanceMethod(self, ni), class_getInstanceMethod(self, vdcni));
+
+ // view containment drop ins for <ios5
+ SEL willMoveToPVC = @selector(willMoveToParentViewController:);
+ SEL vdcWillMoveToPVC = @selector(vdc_willMoveToParentViewController:);
+ if (!class_getInstanceMethod(self, willMoveToPVC)) {
+ Method implementation = class_getInstanceMethod(self, vdcWillMoveToPVC);
+ class_addMethod([UIViewController class], willMoveToPVC, method_getImplementation(implementation), "v@:@");
+ }
+
+ SEL didMoveToPVC = @selector(didMoveToParentViewController:);
+ SEL vdcDidMoveToPVC = @selector(vdc_didMoveToParentViewController:);
+ if (!class_getInstanceMethod(self, didMoveToPVC)) {
+ Method implementation = class_getInstanceMethod(self, vdcDidMoveToPVC);
+ class_addMethod([UIViewController class], didMoveToPVC, method_getImplementation(implementation), "v@:");
+ }
+
+ SEL removeFromPVC = @selector(removeFromParentViewController);
+ SEL vdcRemoveFromPVC = @selector(vdc_removeFromParentViewController);
+ if (!class_getInstanceMethod(self, removeFromPVC)) {
+ Method implementation = class_getInstanceMethod(self, vdcRemoveFromPVC);
+ class_addMethod([UIViewController class], removeFromPVC, method_getImplementation(implementation), "v@:");
+ }
+
+ SEL addCVC = @selector(addChildViewController:);
+ SEL vdcAddCVC = @selector(vdc_addChildViewController:);
+ if (!class_getInstanceMethod(self, addCVC)) {
+ Method implementation = class_getInstanceMethod(self, vdcAddCVC);
+ class_addMethod([UIViewController class], addCVC, method_getImplementation(implementation), "v@:@");
+ }
}
+ (void)load {
@@ -1447,26 +1470,22 @@ + (void)load {
@end
-#ifndef __IPHONE_5_0
-
-@implementation UIViewController (UIViewDeckController_ViewContainmentEmulation)
+@implementation UIViewController (UIViewDeckController_ViewContainmentEmulation_Fakes)
-- (void)addChildViewController:(UIViewController *)childController {
-
+- (void)vdc_addChildViewController:(UIViewController *)childController {
+
}
-- (void)removeFromParentViewController {
+- (void)vdc_removeFromParentViewController {
}
-- (void)willMoveToParentViewController:(UIViewController *)parent {
+- (void)vdc_willMoveToParentViewController:(UIViewController *)parent {
}
-- (void)didMoveToParentViewController:(UIViewController *)parent {
+- (void)vdc_didMoveToParentViewController:(UIViewController *)parent {
}
@end
-
-#endif
Please sign in to comment.
Something went wrong with that request. Please try again.