romaonthego / REFrostedViewController

iOS 7/8 style blurred view controller that appears on top of your view controller.
MIT License
2.97k stars 494 forks source link

Change between View Controllers without using didSelectRowAtIndexPath #126

Open brbgyn opened 9 years ago

brbgyn commented 9 years ago

Hi,

I managed to open a specific view of my app using push and the frostedViewController works great. Code in the tableViewController:

viewController = [[ChatViewChat alloc]init];
        MenuNavigationController *navigationController = [[MenuNavigationController alloc] initWithRootViewController:viewController];
        self.frostedViewController.contentViewController = navigationController;
        [self.frostedViewController hideMenuViewController];

The problem is when a second Push is received, this code doesnt work anymore... It only works at the first time it runs. I can't find out why.

Am i loading a new navigation controller above the one that is active ?

Whats the best way to change between View Controllers not using the didSelectRowAtIndexPath method of the tableView ?

Thanks in advance

brbgyn commented 9 years ago

Never mind.

Found out that my code above only works to change between view controllers if the menuViewController (the tableViewController) is on the screen.

Now i`m trying to change between views without having the menu on screen.

brbgyn commented 9 years ago

For anyone with this kind of question, i managed to open the MENU from any location within the app.

Code to call anywhere is

[NSTimer scheduledTimerWithTimeInterval:0
                                     target:[self topViewController] selector:@selector(presentMenuViewController) userInfo:nil repeats:NO];

Set the topViewController (will be the REFrostedViewController)

- (UIViewController *)topViewController{
    return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}

- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
    if (rootViewController.presentedViewController == nil) {
        return rootViewController;
    }

    if ([rootViewController.presentedViewController isMemberOfClass:[UINavigationController class]]) {
        UINavigationController *navigationController = (UINavigationController *)rootViewController.presentedViewController;
        UIViewController *lastViewController = [[navigationController viewControllers] lastObject];
        return [self topViewController:lastViewController];
    }

    UIViewController *presentedViewController = (UIViewController *)rootViewController.presentedViewController;
    return [self topViewController:presentedViewController];
}
akmalabbasov commented 9 years ago

@brbgyn Hi, were you able to change between view controllers programmatically? If yes, could you please give me a hint. Thank you!

brbgyn commented 9 years ago

Hi @akmalabbasov ,

I can't, im no longer using REFrostedViewController. =/

akmalabbasov commented 9 years ago

Hi @brbgyn, Thank you for reply, did you find any other alternative?

brbgyn commented 9 years ago

I'm using MMDrawerController. https://github.com/mutualmobile/MMDrawerController It's the best menu controller i've found. My app: http://itunes.apple.com/app/id859955280

akmalabbasov commented 9 years ago

@brbgyn, but were you able to switch the viewcontrollers programmatically using MMDrawerController?

brbgyn commented 9 years ago

Yep:

UIViewController *viewController = [[view alloc]init];
UINavigationController *nav = [[MMNavigationController alloc] initWithRootViewController:viewController];
[self.mm_drawerController setCenterViewController:nav withCloseAnimation:YES completion:nil];
akmalabbasov commented 9 years ago

@brbgyn, thanks man, you've saved my day!

prasenrevankar commented 8 years ago

Do any one found the solution using REFrostedViewController? I am using Storyboard approach shown in example.

Hackmodford commented 8 years ago

I am also looking for a solution

Edit:

I solved the problem by doing this

[appRootViewController presentMenuViewController];
// the code that changes the view as if you selected a menu option
[appRootViewController hideMenuViewController];