我是iPad
开发人员的新手,
我使用iPad
Xcode 4.
应用程序
但现在我想使用iPad
语言中的Monodeveloper
工具创建C#
应用程序......
其中,我想在orientation
,
我在谷歌搜索但我没有任何语法。
有关详细信息,请参阅我的屏幕截图...
在第一张图片(肖像模式)中,我的桌子位于extremeLeft,在第二张图片(横向模式)中,我希望我的桌子位于极右侧..
我应该怎么做?
我以编程方式创建了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;
}
我们将不胜感激。
提前致谢!!
答案 0 :(得分:2)
您可以覆盖WillRotate
方法,并根据UIScreen.MainScreen
提供的值,在每种情况下应用您想要的确切位置。 E.g。
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);
}