Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# UIScreen.MainScreen.Bounds.Height和UIScreen.MainScreen.Bounds.Width均为0_C#_Ios_Xamarin.ios_Xamarin - Fatal编程技术网

C# UIScreen.MainScreen.Bounds.Height和UIScreen.MainScreen.Bounds.Width均为0

C# UIScreen.MainScreen.Bounds.Height和UIScreen.MainScreen.Bounds.Width均为0,c#,ios,xamarin.ios,xamarin,C#,Ios,Xamarin.ios,Xamarin,我最近对我的Xamarin iOS项目进行了更新,并使用以下代码检索屏幕宽度和高度: if (orientation == UIInterfaceOrientation.LandscapeLeft || orientation == UIInterfaceOrientation.LandscapeRight) return new RectangleF(UIScreen.MainScreen.Bounds.X, UIScreen.MainScreen.Bounds.Y, UIScreen

我最近对我的Xamarin iOS项目进行了更新,并使用以下代码检索屏幕宽度和高度:

if (orientation == UIInterfaceOrientation.LandscapeLeft || orientation == UIInterfaceOrientation.LandscapeRight)
    return new RectangleF(UIScreen.MainScreen.Bounds.X, UIScreen.MainScreen.Bounds.Y, UIScreen.MainScreen.Bounds.Height, UIScreen.MainScreen.Bounds.Width);
但是,现在随着更新,边界是使用CGRect设置的,因此我的代码更改为:

if (orientation == UIInterfaceOrientation.LandscapeLeft || orientation == UIInterfaceOrientation.LandscapeRight)
    return new CGRect(UIScreen.MainScreen.Bounds.X, UIScreen.MainScreen.Bounds.Y, UIScreen.MainScreen.Bounds.Height, UIScreen.MainScreen.Bounds.Width);

现在,当我尝试这样做时,高度和宽度返回0。我试图创建一个新项目,尝试同样的事情,但我遇到了同样的问题。现在如何检索主屏幕的宽度和高度?

这似乎是Visual Studio插件中的一个错误,以前有过报告:

解决方法是同时使用Xamarin Studio(在Mac上)


如果您能在您的项目中提交一个bug,以便我们能够修复它,我们将不胜感激。

您使用的是Xamarin Studio还是Visual Studio?我使用的是Visual Studio?您使用的是哪种生命周期方法?