Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.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
Iphone monotouch可在景观模式和纵向模式下旋转_Iphone_Ipad_Uitableview_Xamarin.ios_Orientation - Fatal编程技术网

Iphone monotouch可在景观模式和纵向模式下旋转

Iphone monotouch可在景观模式和纵向模式下旋转,iphone,ipad,uitableview,xamarin.ios,orientation,Iphone,Ipad,Uitableview,Xamarin.ios,Orientation,我是新来的iPaddeveloper 我已经使用Xcode 4在objective c中创建了两三个iPad应用程序。 但现在我想用C#语言中的Monodeveloper工具创建iPad应用程序 其中,我想在方向上移动我的tableView 我在谷歌上搜索过,但没有任何语法 有关详细信息,请参见我的屏幕截图 在第一个图像(纵向模式)中,我的桌子位于最右侧,在第二个图像(横向模式)中,我希望我的桌子位于最右侧 我该怎么做 我通过编程创建了tableview,下面是代码片段 public over

我是新来的
iPad
developer

我已经使用
Xcode 4在objective c中创建了两三个
iPad
应用程序。

但现在我想用
C#
语言中的
Monodeveloper
工具创建
iPad
应用程序

其中,我想在
方向上移动我的tableView

我在谷歌上搜索过,但没有任何语法

有关详细信息,请参见我的屏幕截图

在第一个图像(纵向模式)中,我的桌子位于最右侧,在第二个图像(横向模式)中,我希望我的桌子位于最右侧

我该怎么做

我通过编程创建了tableview,下面是代码片段

public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
            Gainer();   //method call
                UITableView Table=new UITableView();
            Table.Frame=new RectangleF(20,200,400,400);
            Table.Source=new TableViewDataSource(TopGainer); //passing parameter to tableview datasource 
            this.View.AddSubview(Table);


        }

public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
        {
            // Return true for supported orientations
            return true;
        }
任何帮助都将不胜感激。


提前感谢

您可以覆盖
WillRotate
方法,并根据
UIScreen.MainScreen
提供的值在任何情况下应用所需的确切位置。例如

    public override void WillRotate (UIInterfaceOrientation toInterfaceOrientation, double duration)
    {
        switch (toInterfaceOrientation) {
        case UIInterfaceOrientation.LandscapeLeft:
        case UIInterfaceOrientation.LandscapeRight:
            Table.Frame = new RectangleF (UIScreen.MainScreen.Bounds.Width - 20 - Table.Frame.Width, 200, 400, 400);
            break;
        case UIInterfaceOrientation.Portrait:
        case UIInterfaceOrientation.PortraitUpsideDown:
            Table.Frame = new RectangleF (20, 200, 400, 400);
            break;
        }
        base.WillRotate (toInterfaceOrientation, duration);
    }

我认为你应该学习Montouch教程(),如果你知道如何用ObjC解决问题,你应该可以很容易地将它们翻译成C#/Monotouch.dude,我想在我的ViewDidLoad()方法中调用这个方法我应该如何调用它?你可以复制相同的代码(
开关
)在
viewdiload
中调用
base.viewdiload…
但是,当您旋转设备时,不会调用此函数(因此,除非在加载之前旋转设备,否则对齐调整将不起作用)。不要复制代码,只需自己调用传递参数的方法:WillRotate(InterfaceOrientation,0);