首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIScreen.MainScreen.Bounds.Height和UIScreen.MainScreen.Bounds.Width都是0

UIScreen.MainScreen.Bounds.Height和UIScreen.MainScreen.Bounds.Width都是0
EN

Stack Overflow用户
提问于 2014-10-13 14:22:23
回答 1查看 692关注 0票数 0

最近,我完成并更新了我的Xamarin iOS项目,我可以调用以下代码来检索屏幕的宽度和高度:

代码语言:javascript
复制
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设置了更新的边界,所以我的代码已经更改为:

代码语言:javascript
复制
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。我试图创建一个新的项目,并尝试同样的事情,但我遇到了同样的问题。现在如何检索主屏幕的宽度和高度?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-14 07:41:07

这看起来像是Visual插件中的一个bug,之前已经报道过:80994

解决办法是在此期间使用Xamarin (在Mac上)。

如果您能在http://bugzilla.xamarin.com上与您的项目一起提交一个bug,我们将不胜感激,这样我们就可以修复它。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26342281

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档