- Avoid switching to ViewController if it's the same class type as the current view controller, and instead just close the slide menu

- this option is configurable by setting a bool called avoidSwitchingToSameClassViewController
This commit is contained in:
Aryan Gh 2013-04-27 10:18:35 -07:00
parent d8867cfb3e
commit 4c74a5b105
2 changed files with 8 additions and 0 deletions

View File

@ -22,6 +22,7 @@ typedef enum{
@interface SlideNavigationController : UINavigationController <UINavigationControllerDelegate>
@property (nonatomic, assign) BOOL avoidSwitchingToSameClassViewController;
@property (nonatomic, strong) UIViewController *righMenu;
@property (nonatomic, strong) UIViewController *leftMenu;
@property (nonatomic, strong) UIBarButtonItem *leftbarButtonItem;

View File

@ -64,6 +64,7 @@ static SlideNavigationController *singletonInstance;
- (void)setup
{
self.avoidSwitchingToSameClassViewController = YES;
singletonInstance = self;
self.delegate = self;
@ -81,6 +82,12 @@ static SlideNavigationController *singletonInstance;
- (void)switchViewController:(UIViewController *)viewController withCompletion:(void (^)())completion
{
if (self.avoidSwitchingToSameClassViewController && [self.topViewController isKindOfClass:viewController.class])
{
[self closeMenuWithCompletion:completion];
return;
}
__block CGRect rect = self.view.frame;
if ([self isMenuOpen])