Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.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# Monotouch UIScreen.MainScreen.Bounds未正确更新_C#_Ipad - Fatal编程技术网

C# Monotouch UIScreen.MainScreen.Bounds未正确更新

C# Monotouch UIScreen.MainScreen.Bounds未正确更新,c#,ipad,C#,Ipad,在mViewController.xib.cs类中,我需要随时确定屏幕高度/宽度。因此,我覆盖了以下内容。我让调试器研究了这些方法,奇怪的是,无论iPad处于哪种旋转,它都显示我的高度是1024,宽度是768,而实际上它应该互换,这取决于iPad纵向或横向的方向。有人能告诉我我做错了什么吗 public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrien

在mViewController.xib.cs类中,我需要随时确定屏幕高度/宽度。因此,我覆盖了以下内容。我让调试器研究了这些方法,奇怪的是,无论iPad处于哪种旋转,它都显示我的高度是1024,宽度是768,而实际上它应该互换,这取决于iPad纵向或横向的方向。有人能告诉我我做错了什么吗

    public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
    {

        RectangleF screeninfo = UIScreen.MainScreen.Bounds;

        float height = screeninfo.Height;
        float width = screeninfo.Width;

        return true;
    }

    public override void DidRotate( UIInterfaceOrientation fromInterfaceOrientation)
    {

        RectangleF screeninfo = UIScreen.MainScreen.Bounds;

        float height = screeninfo.Height;
        float width = screeninfo.Width;
    }       

这不是单触式故障,也不是您的错误;所有iOS设备都是如此。即使在Xcode中执行此操作:

NSLog(@"%@",NSStringFromCGRect([[UIScreen mainScreen] bounds]));
收益率:

{{0, 0}, {768, 1024}}
无论设备方向如何。只需检查当前设备方向,如果是横向,则切换大小。我不熟悉Monotouch或C,但在Obj-C中我们有[[UIDevice currentDevice]方向]我假设关键字是相似的


请注意:iPad使用objective-c buddy,而不是cBuddy,这一点同样适用于iPad,就像有时候你没有什么特别的选择一样。你认为如果我有选择的话,我会使用objective-c吗。你认为我喜欢在一个没有文件记录,没有帮助,只有你一个人的环境中工作吗。但是听着,我需要这份工作,它支付账单。Monotouch是最好的。