SIGABRT:对象引用未设置到对象 SetStatusBarColor Xamarin 的实例 iOS
SIGABRT: Object reference not set to an instance of an object SetStatusBarColor Xamarin iOS
我在将应用程序提交到 AppStore 时遇到崩溃 SIGABRT: Object reference not set to an instance of an object
。我检查了 Apple 的日志文件。此时注意到:
protected override void OnAppearing()
{
base.OnAppearing();
var statusbar = DependencyService.Get<IStatusBarPlatformSpecific>();
statusbar.SetStatusBarColor(Color.FromHex("f1f1f1"));
}
IStatusBarPlatformSpecific.cs
public interface IStatusBarPlatformSpecific
{
void SetStatusBarColor(Color color);
}
受影响最大OS:15.4.1
期待大家的解答。谢谢
您应该得到如下 statusbar
:
UIView statusBar = new UIView(UIApplication.SharedApplication.KeyWindow.WindowScene.StatusBarManager.StatusBarFrame);
if(statusBar == null)
{
//throw a meaningful exception or give some useful feedback!
return;
}
else
{
statusBar.BackgroundColor = color.AddLuminosity(0).ToUIColor();
UIApplication.SharedApplication.KeyWindow.AddSubview(statusBar);
}
我在将应用程序提交到 AppStore 时遇到崩溃 SIGABRT: Object reference not set to an instance of an object
。我检查了 Apple 的日志文件。此时注意到:
protected override void OnAppearing()
{
base.OnAppearing();
var statusbar = DependencyService.Get<IStatusBarPlatformSpecific>();
statusbar.SetStatusBarColor(Color.FromHex("f1f1f1"));
}
IStatusBarPlatformSpecific.cs
public interface IStatusBarPlatformSpecific
{
void SetStatusBarColor(Color color);
}
受影响最大OS:15.4.1
期待大家的解答。谢谢
您应该得到如下 statusbar
:
UIView statusBar = new UIView(UIApplication.SharedApplication.KeyWindow.WindowScene.StatusBarManager.StatusBarFrame);
if(statusBar == null)
{
//throw a meaningful exception or give some useful feedback!
return;
}
else
{
statusBar.BackgroundColor = color.AddLuminosity(0).ToUIColor();
UIApplication.SharedApplication.KeyWindow.AddSubview(statusBar);
}