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: [email protected]") 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.
SLComposeServiceViewController height issue
805 views Asked by Kashif At
2
There are 2 answers
2
On
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.
SLComposeServiceViewControllerstoredSLComposeSheetConfigurationItemintablView, so you need to accesstableViewby travelling onsubViewand callscrollToRowfor bottom position will fix your issue.Solution 1:
Add following code in
ShareViewController.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.