最近,我完成并更新了我的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。我试图创建一个新的项目,并尝试同样的事情,但我遇到了同样的问题。现在如何检索主屏幕的宽度和高度?
发布于 2014-10-14 07:41:07
这看起来像是Visual插件中的一个bug,之前已经报道过:80994
解决办法是在此期间使用Xamarin (在Mac上)。
如果您能在http://bugzilla.xamarin.com上与您的项目一起提交一个bug,我们将不胜感激,这样我们就可以修复它。
https://stackoverflow.com/questions/26342281
复制相似问题