Просмотр исходного кода

Add some polish to the 3D explorer

Also fix a bug in FLEXTableViewController where a section header would appear in plain tables with no header

fhs
Tanner Bennett лет назад: 6
Родитель
Сommit
b221da7021

+ 3 - 1
Classes/Core/FLEXTableViewController.m

@@ -290,7 +290,9 @@ CGFloat const kFLEXDebounceForExpensiveIO = 0.5;
 /// Not having a title in the first section looks weird with a rounded-corner table view style
 /// Not having a title in the first section looks weird with a rounded-corner table view style
 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
     if (@available(iOS 13, *)) {
     if (@available(iOS 13, *)) {
-        return @" "; // For inset grouped style
+        if (self.style == UITableViewStyleInsetGrouped) {
+            return @" ";
+        }
     }
     }
 
 
     return nil; // For plain/gropued style
     return nil; // For plain/gropued style

+ 5 - 12
Classes/ViewHierarchy/FLEXHierarchyViewController.m

@@ -112,8 +112,6 @@ typedef NS_ENUM(NSUInteger, FLEXHierarchyViewMode) {
 
 
 - (void)setMode:(FLEXHierarchyViewMode)mode {
 - (void)setMode:(FLEXHierarchyViewMode)mode {
     if (mode != _mode) {
     if (mode != _mode) {
-        _mode = mode;
-
         // The tree view controller is our top stack view controller, and
         // The tree view controller is our top stack view controller, and
         // changing the mode simply pushes the snapshot view. In the future,
         // changing the mode simply pushes the snapshot view. In the future,
         // I would like to have the 3D toggle button transparently switch
         // I would like to have the 3D toggle button transparently switch
@@ -123,12 +121,17 @@ typedef NS_ENUM(NSUInteger, FLEXHierarchyViewMode) {
             case FLEXHierarchyViewModeTree:
             case FLEXHierarchyViewModeTree:
                 [self popViewControllerAnimated:NO];
                 [self popViewControllerAnimated:NO];
                 self.toolbarHidden = YES;
                 self.toolbarHidden = YES;
+                self.treeViewController.selectedView = self.selectedView;
                 break;
                 break;
             case FLEXHierarchyViewMode3DSnapshot:
             case FLEXHierarchyViewMode3DSnapshot:
                 [self pushViewController:self.snapshotViewController animated:NO];
                 [self pushViewController:self.snapshotViewController animated:NO];
                 self.toolbarHidden = NO;
                 self.toolbarHidden = NO;
+                self.snapshotViewController.selectedView = self.selectedView;
                 break;
                 break;
         }
         }
+
+        // Change this last so that self.selectedView works right above
+        _mode = mode;
     }
     }
 }
 }
 
 
@@ -141,14 +144,4 @@ typedef NS_ENUM(NSUInteger, FLEXHierarchyViewMode) {
     }
     }
 }
 }
 
 
-
-//#pragma mark - FLEXSearchResultsUpdating
-//
-//- (void)updateSearchResults:(NSString *)newText {
-//    [self.treeViewController updateSearchResults:newText];
-//
-//    // TODO: switch between views at tap and full hierarchy
-//    [self.snapshotViewController updateSearchResults:newText];
-//}
-
 @end
 @end

+ 3 - 2
Classes/ViewHierarchy/SnapshotExplorer/FHSViewController.m

@@ -11,8 +11,8 @@
 #import "FLEXColor.h"
 #import "FLEXColor.h"
 #import "FLEXAlert.h"
 #import "FLEXAlert.h"
 #import "NSArray+Functional.h"
 #import "NSArray+Functional.h"
-#import "FLEXHierarchyViewController.h"
 #import "FLEXWindow.h"
 #import "FLEXWindow.h"
+#import "FLEXHierarchyViewController.h"
 
 
 BOOL const kFHSViewControllerExcludeFLEXWindows = YES;
 BOOL const kFHSViewControllerExcludeFLEXWindows = YES;
 
 
@@ -197,7 +197,7 @@ BOOL const kFHSViewControllerExcludeFLEXWindows = YES;
 #pragma mark Helper
 #pragma mark Helper
 
 
 - (FHSViewSnapshot *)snapshotForView:(UIView *)view {
 - (FHSViewSnapshot *)snapshotForView:(UIView *)view {
-    if (!view) return nil;
+    if (!view || !self.snapshots.count) return nil;
 
 
     for (FHSViewSnapshot *snapshot in self.snapshots) {
     for (FHSViewSnapshot *snapshot in self.snapshots) {
         FHSViewSnapshot *found = [snapshot snapshotForView:view];
         FHSViewSnapshot *found = [snapshot snapshotForView:view];
@@ -206,6 +206,7 @@ BOOL const kFHSViewControllerExcludeFLEXWindows = YES;
         }
         }
     }
     }
 
 
+    // Error: we have snapshots but the view we requested is not in one
     @throw NSInternalInconsistencyException;
     @throw NSInternalInconsistencyException;
     return nil;
     return nil;
 }
 }