From ce833b32c770475a2668067df878cdd094e2a4a8 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sat, 1 Jan 2022 01:00:56 +0200 Subject: iOS: Showing activity views on iPad On iPad, activity views are popovers and require information about the source. The UI doesn't provide this, though, so just use the long-press tap position for now. --- src/ios.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/ios.m') diff --git a/src/ios.m b/src/ios.m index 69e09419..82596ffd 100644 --- a/src/ios.m +++ b/src/ios.m @@ -25,6 +25,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "audio/player.h" #include "ui/command.h" #include "ui/window.h" +#include "ui/touch.h" #include #include @@ -541,7 +542,18 @@ static void openActivityView_(NSArray *activityItems) { [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil]; - [viewController_(get_Window()) presentViewController:actView animated:YES completion:nil]; + iWindow *win = get_Window(); + UIViewController *viewCtl = viewController_(win); + UIPopoverPresentationController *popover = [actView popoverPresentationController]; + if (popover) { + [popover setSourceView:[viewCtl view]]; + iInt2 tapPos = latestTapPosition_Touch(); + tapPos.x /= win->pixelRatio; + tapPos.y /= win->pixelRatio; + [popover setSourceRect:(CGRect){{tapPos.x - 10, tapPos.y - 10}, {20, 20}}]; + [popover setCanOverlapSourceViewRect:YES]; + } + [viewCtl presentViewController:actView animated:YES completion:nil]; } void openTextActivityView_iOS(const iString *text) { -- cgit v1.2.3