Fix file presentation on iPadOS not working

This commit is contained in:
Salman Alshamrani
2025-01-21 03:21:59 -05:00
parent 0628d99d11
commit e461d93e8e

View File

@@ -3,6 +3,7 @@
using System;
using System.IO;
using CoreGraphics;
using Foundation;
using UIKit;
using UniformTypeIdentifiers;
@@ -26,16 +27,24 @@ namespace osu.Framework.iOS
if (documentInteraction.PresentPreview(true))
return true;
// Since file menus on iPadOS appear in a popover-like style, UIDocumentInteractionController requires specifying
// a rectangle in the present functions to display the menu as a popover around that rectangle.
// Ultimately, we want to be given a rectangle by the game so the popover doesn't look out of place,
// but for the time being, specify CGRectZero to make the popover display at the top left.
var gameView = window.ViewController.View!;
return documentInteraction.PresentOpenInMenu(gameView.Bounds, gameView, true);
return documentInteraction.PresentOpenInMenu(CGRect.Empty, gameView, true);
}
public bool PresentFile(string filename)
{
setupViewController(filename);
// Since file menus on iPadOS appear in a popover-like style, UIDocumentInteractionController requires specifying
// a rectangle in the present functions to display the menu as a popover around that rectangle.
// Ultimately, we want to be given a rectangle by the game so the popover doesn't look out of place,
// but for the time being, specify CGRectZero to make the popover display at the top left.
var gameView = window.ViewController.View!;
return documentInteraction.PresentOptionsMenu(gameView.Bounds, gameView, true);
return documentInteraction.PresentOptionsMenu(CGRect.Empty, gameView, true);
}
private void setupViewController(string filename)