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

Carousel header works on all supported iOS versions

Tanner Bennett пре 6 година
родитељ
комит
135c8d05c1

+ 2 - 2
Classes/Core/Controllers/FLEXTableViewController.m

@@ -137,7 +137,7 @@ CGFloat const kFLEXDebounceForExpensiveIO = 0.5;
     } else if (self.showsCarousel) {
         return self.carousel.selectedIndex;
     } else {
-        return NSNotFound;
+        return 0;
     }
 }
 
@@ -318,10 +318,10 @@ CGFloat const kFLEXDebounceForExpensiveIO = 0.5;
         self.carousel.frame = FLEXRectSetHeight(
             self.carousel.frame, self.carousel.intrinsicContentSize.height
         );
+        self.carousel.frame = FLEXRectSetY(self.carousel.frame, 0);
     }
     
     self.tableView.tableHeaderView = self.tableView.tableHeaderView;
-    [self.tableView layoutIfNeeded];
 }
 
 - (void)addCarousel:(FLEXScopeCarousel *)carousel {

+ 0 - 24
Classes/Core/Views/FLEXTableView.m

@@ -41,30 +41,6 @@ FLEXTableViewCellReuseIdentifier const kFLEXCodeFontCell = @"kFLEXCodeFontCell";
 #endif
 }
 
-- (CGFloat)_heightForHeaderInSection:(NSInteger)section {
-    CGFloat height = [super _heightForHeaderInSection:section];
-    if (section == 0) {
-        NSString *title = [self _titleForHeaderInSection:section];
-        if (self.tableHeaderView) {
-            if (!@available(iOS 13, *)) {
-                return height - self.tableHeaderView.frame.size.height + 8;
-            }
-            // On iOS 13, returning an empty title for the table view
-            // messes with the height of the table view later on.
-            // We return a space to work around this.
-            else if ([title isEqualToString:@" "]) {
-                return height - self.tableHeaderView.frame.size.height + 5;
-            }
-        } else {
-            if (@available(iOS 13, *) && [title isEqualToString:@" "]) {
-                return 5;
-            }
-        }
-    }
-
-    return height;
-}
-
 #pragma mark - Initialization
 
 + (id)groupedTableView {