瀏覽代碼

Modify approach to toggling views and menu modals.

This approach seems to eliminate some of the status bar issues we were seeing.
Ryan Olson 10 年之前
父節點
當前提交
81b27b6918
共有 1 個文件被更改,包括 27 次插入21 次删除
  1. 27 21
      Classes/ExplorerToolbar/FLEXExplorerViewController.m

+ 27 - 21
Classes/ExplorerToolbar/FLEXExplorerViewController.m

@@ -841,13 +841,20 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     if (viewsModalShown) {
         [self resignKeyAndDismissViewControllerAnimated:YES completion:nil];
     } else {
-        [self dismissPreviousPresentViewController];
-        NSArray *allViews = [self allViewsInHierarchy];
-        NSDictionary *depthsForViews = [self hierarchyDepthsForViews:allViews];
-        FLEXHierarchyTableViewController *hierarchyTVC = [[FLEXHierarchyTableViewController alloc] initWithViews:allViews viewsAtTap:self.viewsAtTapPoint selectedView:self.selectedView depths:depthsForViews];
-        hierarchyTVC.delegate = self;
-        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:hierarchyTVC];
-        [self makeKeyAndPresentViewController:navigationController animated:YES completion:nil];
+        void (^presentBlock)() = ^{
+            NSArray *allViews = [self allViewsInHierarchy];
+            NSDictionary *depthsForViews = [self hierarchyDepthsForViews:allViews];
+            FLEXHierarchyTableViewController *hierarchyTVC = [[FLEXHierarchyTableViewController alloc] initWithViews:allViews viewsAtTap:self.viewsAtTapPoint selectedView:self.selectedView depths:depthsForViews];
+            hierarchyTVC.delegate = self;
+            UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:hierarchyTVC];
+            [self makeKeyAndPresentViewController:navigationController animated:YES completion:nil];
+        };
+        
+        if (self.presentedViewController) {
+            [self resignKeyAndDismissViewControllerAnimated:NO completion:presentBlock];
+        } else {
+            presentBlock();
+        }
     }
 }
 
@@ -858,21 +865,20 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     if (menuModalShown) {
         [self resignKeyAndDismissViewControllerAnimated:YES completion:nil];
     } else {
-        [self dismissPreviousPresentViewController];
-        FLEXGlobalsTableViewController *globalsViewController = [[FLEXGlobalsTableViewController alloc] init];
-        globalsViewController.delegate = self;
-        [FLEXGlobalsTableViewController setApplicationWindow:[[UIApplication sharedApplication] keyWindow]];
-        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:globalsViewController];
-        [self makeKeyAndPresentViewController:navigationController animated:YES completion:nil];
-    }
-}
-
-- (BOOL)dismissPreviousPresentViewController{
-    BOOL needDismissBeforePresent = self.previousKeyWindow && (self.previousKeyWindow != [UIApplication sharedApplication].keyWindow);
-    if (needDismissBeforePresent) {
-        [self resignKeyAndDismissViewControllerAnimated:NO completion:nil];
+        void (^presentBlock)() = ^{
+            FLEXGlobalsTableViewController *globalsViewController = [[FLEXGlobalsTableViewController alloc] init];
+            globalsViewController.delegate = self;
+            [FLEXGlobalsTableViewController setApplicationWindow:[[UIApplication sharedApplication] keyWindow]];
+            UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:globalsViewController];
+            [self makeKeyAndPresentViewController:navigationController animated:YES completion:nil];
+        };
+        
+        if (self.presentedViewController) {
+            [self resignKeyAndDismissViewControllerAnimated:NO completion:presentBlock];
+        } else {
+            presentBlock();
+        }
     }
-    return needDismissBeforePresent;
 }
 
 - (void)handleDownArrowKeyPressed