uin

UINavigationControllerWithCompletionBlock

The UINavigationControllerWithCompletionBlock missing API !

Showing:

Popularity

Downloads/wk

0

GitHub Stars

141

Maintenance

Last Commit

6yrs ago

Contributors

3

Package

Dependencies

1

License

MIT

Categories

Readme

My other works

[http://leverdeterre.github.io] (http://leverdeterre.github.io)

UINavigationControllerWithCompletionBlock

Twitter License MIT CocoaPods Travis

The UINavigationController missing API ! (push / pop with optional completionBlock). The implementation use the navigationController delegate on UINavigationController itself.

This project provides :

  • A completionBlock to manage your push/pop events,
  • A safe way to push/pop multiple controllers at the same times.

   [self.navigationController popViewControllerAnimated:YES withCompletionBlock:NULL];
   [self.navigationController popViewControllerAnimated:YES withCompletionBlock:NULL];
   [self.navigationController popViewControllerAnimated:YES withCompletionBlock:NULL];
  • No more "Nested pop animation can result in corrupted navigation bar",
  • No more "Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted."
  • No more crash because of deallocated controllers between your multiple animations.

Image

New methods

- (void)pushViewController:(UIViewController *)viewController 
                 animated:(BOOL)animated 
      withCompletionBlock:(JMONavCompletionBlock)completionBlock;

- (void)popViewControllerAnimated:(BOOL)animated 
              withCompletionBlock:(JMONavCompletionBlock)completionBlock;
- (void)popToRootViewControllerAnimated:(BOOL)animated
                    withCompletionBlock:(JMONavCompletionBlock)completionBlock;

Swizzled methods

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated; 
- (UIViewController *)popViewControllerAnimated:(BOOL)animated;

Usage UINavigationController+CompletionBlock

  • (OPTIONAL) Activate Swizzling to redirect push/pop native calls to custom implementation. This swizzling is interesting if you don't want to replace all your push/pop methods, or, if you implement your own NavigationControllerDelegate.
typedef NS_OPTIONS(NSUInteger, UINavigationControllerSwizzlingOption) {
    UINavigationControllerSwizzlingOptionDelegate       = 1 << 0,
    UINavigationControllerSwizzlingOptionOriginalPush   = 1 << 1,
    UINavigationControllerSwizzlingOptionOriginalPop    = 1 << 2
};

+ (void)activateSwizzling;
+ (void)activateSwizzlingWithOptions:(UINavigationControllerSwizzlingOption)options;
  • Use the new pop/push methods (no need swizzling because your are calling custom methods)
[self.navigationController popViewControllerAnimated:YES withCompletionBlock:NULL];
[self.navigationController pushViewController:vc animated:YES withCompletionBlock:^(BOOL successful) {
   NSLog(@"Hi ! Push done !");
}];
  • Use "old" Apple API. (Required Swizzling). The native calls will be redirected to the new custom API with default NULL completionBlock.
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController pushViewController:vc animated:YES];

Installation using pods

Just add the following line in your podfile

pod 'UINavigationControllerWithCompletionBlock'

Image

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100