[iOS] Prevent NRE when page is switched on Appearing (#840)

This commit is contained in:
Samantha Houts 2017-03-27 03:31:04 -07:00 коммит произвёл Rui Marinho
Родитель 9dcce94937
Коммит 1eae24b051
3 изменённых файлов: 59 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,55 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
// Apply the default category of "Issues" to all of the tests in this assembly
// We use this as a catch-all for tests which haven't been individually categorized
#if UITEST
[assembly: NUnit.Framework.Category("Issues")]
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.None, 0, "NRE when switching page on Appearing", PlatformAffected.iOS)]
public class Unreported1 : TestMasterDetailPage
{
static Unreported1 MDP;
class SplashPage : ContentPage
{
protected override void OnAppearing()
{
base.OnAppearing();
// You really shouldn't do this, but we shouldn't crash when you do it. :)
SwitchDetail();
}
}
protected override void Init()
{
MDP = this;
Master = new Page { Title = "Master" };
Detail = new SplashPage();
}
public static void SwitchDetail()
{
MDP.Detail = new ContentPage { Content = new Label { Text = "If this did not crash, this test has passed." }, Padding = 20 };
}
#if UITEST
[Test]
public void Unreported1Test()
{
RunningApp.Screenshot("ensure there is no crash");
}
#endif
}
}

Просмотреть файл

@ -269,6 +269,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla52533.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla53362.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla45874.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Unreported1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla53909.cs" />
<Compile Include="$(MSBuildThisFileDirectory)_Template.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1028.cs" />

Просмотреть файл

@ -200,6 +200,9 @@ namespace Xamarin.Forms.Platform.iOS
void UpdateStatusBarPrefersHidden()
{
if (Element == null)
return;
var animation = ((Page)Element).OnThisPlatform().PreferredStatusBarUpdateAnimation();
if (animation == PageUIStatusBarAnimation.Fade || animation == PageUIStatusBarAnimation.Slide)
UIView.Animate(0.25, () => SetNeedsStatusBarAppearanceUpdate());