[iOS] Use separate UIWindow for UIAlertController #481

Merged
merged 2 commits into from Nov 15, 2016

Conversation

Projects
None yet
6 participants
@pauldipietro
Member

pauldipietro commented Oct 21, 2016

Description of Change

Presently, calling DisplayAlert via Device.BeginInvokeOnMainThread prevents a subsequent use of BeginInvokeOnMainThread to do something such as push a new page prevents it from working. After doing some digging around, some best practices Apple uses according to a reputable SO user suggests that they present a UIAlertController on a new UIWindow. Doing this appears to allow for such behavior to work as expected. DisplayActionSheet's behavior has been tweaked as well and to avoid repetition of code a void PresentAlert(UIAlertController alert) method was added.

bugzilla45743

Bugs Fixed

https://bugzilla.xamarin.com/show_bug.cgi?id=45743

API Changes

None

Behavioral Changes

The DisplayAlert gallery appears to work as usual and a test was added in the case that a second alert is pushed, so presumably there are no odd effects here.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense
Xamarin.Forms.Platform.iOS/Platform.cs
- var vc = GetRenderer(page).ViewController;
- vc.PresentViewController(alert, true, null);
+
+ PresentAlert(alert);

This comment has been minimized.

@hartez

hartez Oct 24, 2016

Member

Looks like page is created and then never used.

@hartez

hartez Oct 24, 2016

Member

Looks like page is created and then never used.

@pauldipietro

This comment has been minimized.

Show comment
Hide comment
@pauldipietro

pauldipietro Oct 24, 2016

Member

Removed the line -- missed it somehow.

Member

pauldipietro commented Oct 24, 2016

Removed the line -- missed it somehow.

@jassmith jassmith merged commit 7f9f253 into master Nov 15, 2016

1 check was pending

Windows-Debug-C8 Started TeamCity Build Xamarin.Forms :: Debug :: Cycle 8 :: Windows Debug
Details

@jimmgarrido jimmgarrido referenced this pull request Mar 30, 2017

Merged

[iOS] Hide alert window before setting result #848

3 of 4 tasks complete

@rmarinho rmarinho deleted the fix-bugzilla45743 branch Jun 22, 2017

@samhouts samhouts added this to the 2.3.4 milestone Jun 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment