我是 iPad
开发者新手,
我已经使用 Xcode 4 在 Objective C 中创建了两个或三个
iPad
应用程序。
但现在我想使用 C#
语言的 Monodeveloper
工具创建 iPad
应用程序...
其中,我想改变我的tableView的方向
,
我在谷歌中搜索,但没有得到任何语法。
有关详细信息,请参阅我的屏幕截图...
在第一张图片(纵向模式)中,我的 table 位于最左边,在第二张图片(横向模式)中,我希望我的 table 位于最右边。
我应该怎么做?
我以编程方式创建了表格 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/