0

我正在使用侧抽屉菜单https://github.com/mutualmobile/MMDrawerController 我无法返回自定义 UIButton。

- (IBAction)doBackAction:(id)sender {
       NSArray *viewControllers=self.navigationController.viewControllers;
    for (UIViewController *viewController in viewControllers) {
         NSLog(@"%@",NSStringFromClass([viewController class]));
        UINavigationController *obj=(UINavigationController *)[self.mm_drawerController centerViewController];

    }
    UINavigationController *nav =
    (UINavigationController *)self.mm_drawerController.centerViewController;
    [nav popToRootViewControllerAnimated:NO];
    [self.navigationController popViewControllerAnimated:YES];
    [self.mm_drawerController closeDrawerAnimated:YES completion:nil];

}

我也试过这个https://github.com/mutualmobile/MMDrawerController/issues/195 我不能让它工作。

4

2 回答 2

0

请试试这个。可能对你有帮助

       for (UIViewController *controller in self.navigationController.viewControllers)
            {


                if ([controller isKindOfClass:[CartVC class]])
                {
                    //Do not forget to import CompareCarsVC.h
                    //                CATransition *transition = [CATransition animation];
                    //                transition.duration = 0.5;
                    //                transition.type = kCATransitionFade;
                    //
                    //                [self.navigationController.view.layer addAnimation:transition forKey:kCATransition];

                    [self.navigationController popToViewController:controller
                                                          animated:NO];
                    break;
                }
            }
于 2016-05-05T13:35:01.183 回答
0

您可能会考虑设置一个全局变量(单例或数据库中的 ea),您使用的 ViewController 来自viewDidDissapear

- (void)viewDidDissapear {
    Singleton.lastViewController = [self class];
}

从那里您可以这样做以了解您来自哪里(ea an IBAction):

// Set your global variable: `NSString` Singleton.lastViewController

[self presentViewController:[[UIStoryboard storyboardWithName:@"Main_iPad" bundle:nil] instantiateViewControllerWithIdentifier:Singleton.lastViewController] animated:YES completion:nil];

我将它用于具有自定义 segue 和编程导航的应用程序。

于 2016-05-05T13:27:29.083 回答