Skip to content

Commit dbf5a7c

Browse files
committed
Removed swizzling of UIViewController's present(Modal)ViewController which breaks UIViewController's presentingViewController property and thereby modal unwind segues.
iOS 5+ uses UIViewController's definesPresentationContext property to determine which controller is parent for a modal view controller. That system should handle presentation just fine even without swizzling.
1 parent 66414ea commit dbf5a7c

File tree

1 file changed

+0
-25
lines changed

1 file changed

+0
-25
lines changed

ViewDeck/IIViewDeckController.m

-25
Original file line numberDiff line numberDiff line change
@@ -3517,21 +3517,6 @@ - (void)setViewDeckController:(IIViewDeckController*)viewDeckController {
35173517
objc_setAssociatedObject(self, viewDeckControllerKey, viewDeckController, OBJC_ASSOCIATION_ASSIGN);
35183518
}
35193519

3520-
- (void)vdc_presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated {
3521-
UIViewController* controller = self.viewDeckController ?: self;
3522-
[controller vdc_presentModalViewController:modalViewController animated:animated]; // when we get here, the vdc_ method is actually the old, real method
3523-
}
3524-
3525-
3526-
#ifdef __IPHONE_5_0
3527-
3528-
- (void)vdc_presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)animated completion:(void (^)(void))completion {
3529-
UIViewController* controller = self.viewDeckController ?: self;
3530-
[controller vdc_presentViewController:viewControllerToPresent animated:animated completion:completion]; // when we get here, the vdc_ method is actually the old, real method
3531-
}
3532-
3533-
#endif
3534-
35353520
- (UINavigationController*)vdc_navigationController {
35363521
UIViewController* controller = self.viewDeckController_core ? self.viewDeckController_core : self;
35373522
return [controller vdc_navigationController]; // when we get here, the vdc_ method is actually the old, real method
@@ -3543,16 +3528,6 @@ - (UINavigationItem*)vdc_navigationItem {
35433528
}
35443529

35453530
+ (void)vdc_swizzle {
3546-
if (![self instancesRespondToSelector:@selector(presentViewController:animated:completion:)]) {
3547-
SEL presentModal = @selector(presentModalViewController:animated:);
3548-
SEL vdcPresentModal = @selector(vdc_presentModalViewController:animated:);
3549-
method_exchangeImplementations(class_getInstanceMethod(self, presentModal), class_getInstanceMethod(self, vdcPresentModal));
3550-
}
3551-
3552-
SEL presentVC = @selector(presentViewController:animated:completion:);
3553-
SEL vdcPresentVC = @selector(vdc_presentViewController:animated:completion:);
3554-
method_exchangeImplementations(class_getInstanceMethod(self, presentVC), class_getInstanceMethod(self, vdcPresentVC));
3555-
35563531
SEL nc = @selector(navigationController);
35573532
SEL vdcnc = @selector(vdc_navigationController);
35583533
method_exchangeImplementations(class_getInstanceMethod(self, nc), class_getInstanceMethod(self, vdcnc));

0 commit comments

Comments
 (0)