iPhone中的Monotouch自动调整大小视图
问题描述:
我在界面构建器中创建了一个视图,其中包含另一个视图(内容区域)和底部的按钮栏。iPhone中的Monotouch自动调整大小视图
层次结构是:
->View
--->mapContainer UIView
----->map MKMapView
----->OverlayView UIView
--->ToolBar UIToolBar
我想mapContainer来调整到满窗口时,工具栏隐藏。 我想将地图和OverlayView调整为mapContainer大小
我已经尝试了下面的代码,但它没有效果。请指教?
public override void ViewDidLoad()
{
base.ViewDidLoad();
this.mapContainer.AutosizesSubviews = true ;
this.View.AutosizesSubviews = true ;
try
{
this.mapContainer.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth ;
this.map.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth ;
this.map.SizeToFit();
this.mapContainer.SizeToFit();
this.map.SizeToFit();
this.View.Frame = new System.Drawing.RectangleF(0,0,this.View.Frame.Width, this.View.Frame.Height);
this.mapContainer.LayoutSubviews();
}
catch(Exception ex)
{
Console.Write(ex.ToString());
}
}
答
看看这篇文章可能是这可以帮助不相关的MonoTouch you.Its但它会给如何安排在一起IB元素很好的概念。 http://programmingobsession.blogspot.com/2009/05/real-world-iphone-rotation-part-1.html
答
您还可以尝试重写覆盖方法中的子视图public override void LayoutSubviews与您的类。
在那里你可以重置所有帧的帧。 SizeToFit()方法有一种不能工作的趋势,因为它的名字听起来......因此,首先要适合尺寸,然后重置框架。
希望它有帮助:)