Преглед изворни кода

Change how simulator shortcuts present tools

Tanner Bennett пре 6 година
родитељ
комит
873e79d2c0
1 измењених фајлова са 14 додато и 3 уклоњено
  1. 14 3
      Classes/Manager/FLEXManager+Extensibility.m

+ 14 - 3
Classes/Manager/FLEXManager+Extensibility.m

@@ -219,10 +219,21 @@
 
 
 - (void)toggleTopViewControllerOfClass:(Class)class {
 - (void)toggleTopViewControllerOfClass:(Class)class {
     UINavigationController *topViewController = (id)self.topViewController;
     UINavigationController *topViewController = (id)self.topViewController;
-    if ([topViewController isKindOfClass:[UINavigationController class]] &&
-        [topViewController.topViewController isKindOfClass:[class class]]) {
-        [topViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
+    if ([topViewController isKindOfClass:[FLEXNavigationController class]]) {
+        if ([topViewController.topViewController isKindOfClass:[class class]]) {
+            if (topViewController.viewControllers.count == 1) {
+                // Dismiss since we are already presenting it
+                [topViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
+            } else {
+                // Pop since we are viewing it but it's not the only thing on the stack
+                [topViewController popViewControllerAnimated:YES];
+            }
+        } else {
+            // Push it on the existing navigation stack
+            [topViewController pushViewController:[class new] animated:YES];
+        }
     } else {
     } else {
+        // Present it in an entirely new navigation controller
         [topViewController presentViewController:
         [topViewController presentViewController:
             [FLEXNavigationController withRootViewController:[class new]]
             [FLEXNavigationController withRootViewController:[class new]]
         animated:YES completion:nil];
         animated:YES completion:nil];