2

My Share extension's view height seems to be rendered smaller than needed to accommodate the SLComposeSheetConfigurationItem. as you can see in attachment, it seems to be cut off from the bottom ("to: test@email.com") and I have to scroll it to see it all. Any idea why it might be happening. I am not customizing it in any way.screenshot

Kashif
  • 4,642
  • 7
  • 44
  • 97

2 Answers2

1

SLComposeServiceViewController stored SLComposeSheetConfigurationItem in tablView, so you need to access tableView by travelling on subView and call scrollToRow for bottom position will fix your issue.

Solution 1:

Add following code in ShareViewController.

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    if let slSheet = self.children.first as? UINavigationController,
        let tblView = slSheet.children.first?.view.subviews.first as? UITableView
    {
            // Scroll tablView to bottom
            tblView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .bottom, animated: true)
    }
}

Solution 2:

Change the row height will fix your issue, But make sure it is exactly height value which you want, I have used as per my requirements. Default value is 44.

tblView.rowHeight = 35
tblView.separatorStyle = .none
Sagar Chauhan
  • 5,715
  • 2
  • 22
  • 56
1

This seems to be an issue with iOS 13. The sheet's height is controlled by the system. Setting the preferredContentSize property doesn't have any effect. I'm using the following workaround:

override func viewDidLoad() {
    super.viewDidLoad()

    if #available(iOS 13.0, *) {
        _ = NotificationCenter.default.addObserver(forName: UIResponder.keyboardDidShowNotification, object: nil, queue: .main) { (_) in
            if let layoutContainerView = self.view.subviews.last {
                layoutContainerView.frame.size.height += 10
            }
        }
    }
}

The last subview of self.view is an instance of UILayoutContainerView, which is a private UIKit class. This class determines the size of the share dialog, but doesn't have any constraints attached to it. Therefore I have to set the frame property directly. I'm using the keyboardDidShowNotification callback because the frame is updated by the system when the keyboard appears.

If anyone comes up with a better solution, please let me know.

Felix
  • 776
  • 8
  • 16