iphone - 单点触控在横向模式和纵向模式下旋转

标签 iphone ipad uitableview xamarin.ios orientation

我是 iPad 开发者新手,

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

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

其中,我想改变我的tableView的方向

我在谷歌中搜索,但没有得到任何语法。

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

在第一张图片(纵向模式)中,我的 table 位于最左边,在第二张图片(横向模式)中,我希望我的 table 位于最右边。

screenshot 我应该怎么做?

我以编程方式创建了表格 View ,这是代码片段,

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);
    }

关于iphone - 单点触控在横向模式和纵向模式下旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9376893/

相关文章:

ios - iPhone X 上额外的底部空间/填充?

ios - 将数据从 iOS 应用程序安全地发送到服务器上的 php 脚本

ipad - 问题与presentPopoverFromRect 并在iOS 7 中设置Popover 内容大小

iphone - 在 iPhone/iPad 上保存 HLS 流

ios - UITableView - 行 - 多重对齐

iphone - 如何向上移动 tableView 以便从底部弹出一个 View ,使其不在 iPhone 的表格顶部

iphone - 方法的返回值

iphone - 将应用程序提交到 itune connect 使用不同的默认语言然后是英语(未找到应用程序记录。)

iphone - 在屏幕的特定部分打开 zbar 扫描仪

ios - 正在调用 cellForRowAtIndexPath : ever practical?