Skip to content

Commit

Permalink
Fixed UINavigationController swizzling
Browse files Browse the repository at this point in the history
If PSStackedViewController was created more than once, the swizzling was 
reverted every two creations.
  • Loading branch information
jeanregisser committed Apr 2, 2013
1 parent fb9bf4f commit 43407af
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions PSStackedView/PSStackedViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ - (void)sharedInitialization {
cornerRadius_ = 6.0f;

#ifdef ALLOW_SWIZZLING_NAVIGATIONCONTROLLER
PSSVLog("Swizzling UIViewController.navigationController");
Method origMethod = class_getInstanceMethod([UIViewController class], @selector(navigationController));
Method overrideMethod = class_getInstanceMethod([UIViewController class], @selector(navigationControllerSwizzled));
method_exchangeImplementations(origMethod, overrideMethod);
static dispatch_once_t token;

dispatch_once(&token, ^{
PSSVLog("Swizzling UIViewController.navigationController");
Method origMethod = class_getInstanceMethod([UIViewController class], @selector(navigationController));
Method overrideMethod = class_getInstanceMethod([UIViewController class], @selector(navigationControllerSwizzled));
method_exchangeImplementations(origMethod, overrideMethod);
});
#endif

}
Expand Down

0 comments on commit 43407af

Please sign in to comment.