From 5fc9f3396565d6a99d7083b182919ccb94737b07 Mon Sep 17 00:00:00 2001 From: Norbel AMBANUMBEN Date: Thu, 6 Jun 2024 09:51:49 +0100 Subject: [PATCH] fix: alert modal behaviour on iOS --- Podfile.lock | 1 - ooniprobe/View/Settings/SettingsTableViewController.m | 8 ++++++++ .../View/Settings/WebsiteCategoriesTableViewController.m | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Podfile.lock b/Podfile.lock index d7085ab3..f35c0367 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -113,5 +113,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 3df4eef5a3f5aeba6a6df642bb5d669cff0662b0 - COCOAPODS: 1.15.2 diff --git a/ooniprobe/View/Settings/SettingsTableViewController.m b/ooniprobe/View/Settings/SettingsTableViewController.m index d53c24a8..2d2305c7 100644 --- a/ooniprobe/View/Settings/SettingsTableViewController.m +++ b/ooniprobe/View/Settings/SettingsTableViewController.m @@ -253,6 +253,14 @@ -(IBAction)selectLanguage:(id)sender{ position:CSToastPositionBottom]; }]]; } + + // Check if the device is an iPad + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + alert.popoverPresentationController.sourceView = self.view; + alert.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width, self.view.bounds.size.height, 1.0, 1.0); + alert.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp; + } + [self presentViewController:alert animated:YES completion:nil]; } diff --git a/ooniprobe/View/Settings/WebsiteCategoriesTableViewController.m b/ooniprobe/View/Settings/WebsiteCategoriesTableViewController.m index a63099fc..89ba9ae8 100644 --- a/ooniprobe/View/Settings/WebsiteCategoriesTableViewController.m +++ b/ooniprobe/View/Settings/WebsiteCategoriesTableViewController.m @@ -77,6 +77,13 @@ - (IBAction)showListActions:(id)sender { [SettingsUtility updateAllWebsiteCategories:false]; [self.navigationController popViewControllerAnimated:YES]; }]]; + + // Check if the device is an iPad + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + alert.popoverPresentationController.sourceView = self.view; + alert.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width / 2.0, self.view.bounds.size.height / 2.0, 1.0, 1.0); + } + [self presentViewController:alert animated:YES completion:nil]; }