Fixes ControllerInputsViewController UI on iPad
This commit is contained in:
parent
d333672b95
commit
adccf8fca5
@ -1048,6 +1048,7 @@
|
|||||||
<objects>
|
<objects>
|
||||||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="0QR-U9-gtx" customClass="RSTNavigationController" sceneMemberID="viewController">
|
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="0QR-U9-gtx" customClass="RSTNavigationController" sceneMemberID="viewController">
|
||||||
<toolbarItems/>
|
<toolbarItems/>
|
||||||
|
<value key="contentSizeForViewInPopover" type="size" width="375" height="667"/>
|
||||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" barStyle="black" prompted="NO"/>
|
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" barStyle="black" prompted="NO"/>
|
||||||
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" barStyle="black" id="Y5H-O6-CQ5">
|
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" barStyle="black" id="Y5H-O6-CQ5">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
|
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
|
||||||
|
|||||||
@ -40,6 +40,8 @@ class ControllerInputsViewController: UIViewController
|
|||||||
|
|
||||||
private var activeCalloutView: InputCalloutView?
|
private var activeCalloutView: InputCalloutView?
|
||||||
|
|
||||||
|
private var _didLayoutSubviews = false
|
||||||
|
|
||||||
@IBOutlet private var actionsMenuViewControllerHeightConstraint: NSLayoutConstraint!
|
@IBOutlet private var actionsMenuViewControllerHeightConstraint: NSLayoutConstraint!
|
||||||
@IBOutlet private var cancelTapGestureRecognizer: UITapGestureRecognizer!
|
@IBOutlet private var cancelTapGestureRecognizer: UITapGestureRecognizer!
|
||||||
|
|
||||||
@ -65,7 +67,15 @@ class ControllerInputsViewController: UIViewController
|
|||||||
|
|
||||||
self.gameViewController.controllerView.addReceiver(self)
|
self.gameViewController.controllerView.addReceiver(self)
|
||||||
|
|
||||||
self.navigationController?.navigationBar.barStyle = .black
|
if let navigationController = self.navigationController, #available(iOS 13, *)
|
||||||
|
{
|
||||||
|
navigationController.overrideUserInterfaceStyle = .dark
|
||||||
|
navigationController.navigationBar.scrollEdgeAppearance = navigationController.navigationBar.standardAppearance // Fixes invisible navigation bar on iPad.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self.navigationController?.navigationBar.barStyle = .black
|
||||||
|
}
|
||||||
|
|
||||||
NSLayoutConstraint.activate([self.gameViewController.gameView.centerYAnchor.constraint(equalTo: self.actionsMenuViewController.view.centerYAnchor)])
|
NSLayoutConstraint.activate([self.gameViewController.gameView.centerYAnchor.constraint(equalTo: self.actionsMenuViewController.view.centerYAnchor)])
|
||||||
|
|
||||||
@ -81,6 +91,23 @@ class ControllerInputsViewController: UIViewController
|
|||||||
{
|
{
|
||||||
self.actionsMenuViewControllerHeightConstraint.constant = self.actionsMenuViewController.preferredContentSize.height
|
self.actionsMenuViewControllerHeightConstraint.constant = self.actionsMenuViewController.preferredContentSize.height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let window = self.view.window, !_didLayoutSubviews
|
||||||
|
{
|
||||||
|
var traits = DeltaCore.ControllerSkin.Traits.defaults(for: window)
|
||||||
|
traits.orientation = .portrait
|
||||||
|
|
||||||
|
if traits.device == .ipad
|
||||||
|
{
|
||||||
|
// Use standard iPhone skins instead of iPad skins.
|
||||||
|
traits.device = .iphone
|
||||||
|
traits.displayType = .standard
|
||||||
|
}
|
||||||
|
|
||||||
|
self.gameViewController.controllerView.overrideControllerSkinTraits = traits
|
||||||
|
|
||||||
|
_didLayoutSubviews = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool)
|
override func viewDidAppear(_ animated: Bool)
|
||||||
@ -403,6 +430,7 @@ private extension ControllerInputsViewController
|
|||||||
}
|
}
|
||||||
|
|
||||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||||
|
alertController.popoverPresentationController?.barButtonItem = sender
|
||||||
alertController.addAction(.cancel)
|
alertController.addAction(.cancel)
|
||||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("Reset Controls to Defaults", comment: ""), style: .destructive, handler: { (action) in
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("Reset Controls to Defaults", comment: ""), style: .destructive, handler: { (action) in
|
||||||
reset()
|
reset()
|
||||||
@ -562,3 +590,15 @@ extension ControllerInputsViewController: SMCalloutViewDelegate
|
|||||||
self.toggle(calloutView)
|
self.toggle(calloutView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension ControllerInputsViewController: UIAdaptivePresentationControllerDelegate
|
||||||
|
{
|
||||||
|
func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle
|
||||||
|
{
|
||||||
|
switch (traitCollection.horizontalSizeClass, traitCollection.verticalSizeClass)
|
||||||
|
{
|
||||||
|
case (.regular, .regular): return .formSheet // Regular width and height, so display as form sheet
|
||||||
|
default: return .fullScreen // Compact width and/or height, so display full screen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -108,9 +108,18 @@ extension ControllersSettingsViewController
|
|||||||
switch identifier
|
switch identifier
|
||||||
{
|
{
|
||||||
case "controllerInputsSegue":
|
case "controllerInputsSegue":
|
||||||
let controllerInputsViewController = (segue.destination as! UINavigationController).topViewController as! ControllerInputsViewController
|
let navigationController = segue.destination as! UINavigationController
|
||||||
|
|
||||||
|
let controllerInputsViewController = navigationController.topViewController as! ControllerInputsViewController
|
||||||
controllerInputsViewController.gameController = self.gameController
|
controllerInputsViewController.gameController = self.gameController
|
||||||
|
|
||||||
|
if self.view.traitCollection.userInterfaceIdiom == .pad
|
||||||
|
{
|
||||||
|
// For now, only iPads can display ControllerInputsViewController as a form sheet.
|
||||||
|
navigationController.modalPresentationStyle = .formSheet
|
||||||
|
navigationController.presentationController?.delegate = controllerInputsViewController
|
||||||
|
}
|
||||||
|
|
||||||
default: break
|
default: break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user