Przeglądaj źródła

Disallow preview of views with no rect

Tanner Bennett 5 lat temu
rodzic
commit
547bfbaec0

+ 3 - 2
Classes/ObjectExplorers/Sections/Shortcuts/FLEXViewShortcuts.m

@@ -77,8 +77,9 @@
             viewer:^UIViewController *(id view) {
                 return [FLEXImagePreviewViewController previewForView:view];
             }
-            accessoryType:^UITableViewCellAccessoryType(id view) {
-                return UITableViewCellAccessoryDisclosureIndicator;
+            accessoryType:^UITableViewCellAccessoryType(UIView *view) {
+                // Disable preview if bounds are CGRectZero
+                return CGRectIsEmpty(view.bounds) ? UITableViewCellAccessoryDisclosureIndicator : 0;
             }
         ]
     ]];

+ 1 - 1
Classes/Utility/FLEXUtility.m

@@ -135,7 +135,7 @@ BOOL FLEXConstructorsShouldRun() {
 
 + (UIImage *)previewImageForView:(UIView *)view {
     if (CGRectIsEmpty(view.bounds)) {
-        return nil;
+        return [UIImage new];
     }
     
     CGSize viewSize = view.bounds.size;

+ 2 - 4
Classes/ViewHierarchy/FLEXImagePreviewViewController.m

@@ -31,14 +31,12 @@
 }
 
 + (instancetype)forImage:(UIImage *)image {
-    if (!image) {
-        return nil;
-    }
-    
     return [[self alloc] initWithImage:image];
 }
 
 - (id)initWithImage:(UIImage *)image {
+    NSParameterAssert(image);
+    
     self = [super init];
     if (self) {
         self.title = @"Preview";