Monotouch auto resizing views in iphone
- by Tim Bassett
I have created a view in interface builder that contains another view (content area) and a button bar at the bottom.
The hierarchy is as:
->View
--->mapContainer UIView
----->map MKMapView
----->OverlayView UIView
--->ToolBar UIToolBar
I would like the mapContainer to resize to full window when the ToolBar is hidden.
I would like the map and the OverlayView to resize to the mapContainer size
I have attempted the following code, but it has no effect.  Please advise?
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());
  }
}