@@ -458,12 +458,36 @@ open class FormViewController: UIViewController, FormViewControllerProtocol, For
458
458
459
459
if tableView == nil {
460
460
tableView = UITableView ( frame: view. bounds, style: tableViewStyle)
461
- tableView. autoresizingMask = [ . flexibleWidth, . flexibleHeight]
462
461
tableView. cellLayoutMarginsFollowReadableWidth = false
463
462
}
464
463
if tableView. superview == nil {
465
464
view. addSubview ( tableView)
466
465
}
466
+ /**
467
+ * Fix for #1952: `UITableView.scrollRectToVisible(, animated:)` and `UITableView.scrollToRow()` don't work properly
468
+ * in `keyboardWillShow()` due to, what seems to be, a bug in iOS when autoresizing mask is used for a `UIViewController` that is
469
+ * presented modally as `.formSheet/.pageSheet` within a `UINavigationController`.
470
+ * The check below preserves the existing behavior of using autoresizing masks in other cases.
471
+ */
472
+ var useAutoresizingMask = true
473
+ if #available( iOS 13 , * ) {
474
+ if presentingViewController != nil && navigationController != nil {
475
+ useAutoresizingMask = false
476
+
477
+ // Need to set the background color as otherwise black shows underneath the translucent navigation bar.
478
+ view. backgroundColor = . systemBackground
479
+ tableView. translatesAutoresizingMaskIntoConstraints = false
480
+ NSLayoutConstraint . activate ( [
481
+ tableView. topAnchor. constraint ( equalTo: tableView. superview!. safeAreaLayoutGuide. topAnchor) ,
482
+ tableView. bottomAnchor. constraint ( equalTo: tableView. superview!. safeAreaLayoutGuide. bottomAnchor) ,
483
+ tableView. leadingAnchor. constraint ( equalTo: tableView. superview!. safeAreaLayoutGuide. leadingAnchor) ,
484
+ tableView. trailingAnchor. constraint ( equalTo: tableView. superview!. safeAreaLayoutGuide. trailingAnchor)
485
+ ] )
486
+ }
487
+ }
488
+ if useAutoresizingMask {
489
+ tableView. autoresizingMask = [ . flexibleWidth, . flexibleHeight]
490
+ }
467
491
if tableView. delegate == nil {
468
492
tableView. delegate = self
469
493
}
0 commit comments