2

I am using MonoTouch.Dialog within a UIPopoverController to give our iPad users a series of settings to work with. In my app, I am using this CalendarView (http://escoz.com/blog/monotouch-calendar-control-is-here/) so the user can set dates for the application (the settings are used to configure timed locations on a Googlemap).

Anyway, I am experiencing some sizing issues concerning the UIPopoverController... Regardless of how i set the content size, once i click deeper into the tree of .Dialog, the UIPopoverController resizes itself which is causing undesired sizing on said calendar view.

Enclosed is a sample of what Im seeing. You will notice, I have the content sized at 450x420. Once I click any of the options, the popover resizes itself. I want this popover to remain the same size all of the time.

Am I missing something obvious here? Any help would be much appreciated.

Declares and launches popover from myPopOverView.cs:

UIPopoverController myPopOver = new UIPopoverController(new myPopOverView()); 

btnSearch.TouchUpInside += (sender, e) => {
   myPopOver.PopoverContentSize = new SizeF(450f, 420f);
   myPopOver.PresentFromRect (btnPopOver.Frame, this.View, UIPopoverArrowDirection.Down, true);
}   

from myPopOverView.cs:

public override void ViewDidLoad ()
   {
  base.ViewDidLoad ();

  var root = CreateRoot ();

  var dv = new DialogViewController (root, true);
  this.PushViewController (dv, true);
}

RootElement CreateRoot ()
    {

        return new RootElement ("Find Stuff") {
                new Section (){
                    new RootElement ("States", new RadioGroup (0)){
                        new Section (){
                            new RadioElement ("New York"),
                            new RadioElement ("California"),
                            new RadioElement ("Texas"), 
                        }
                    }  , 
                }  ,
                new Section (){
                    new RootElement ("Places", new RadioGroup (0)){
                        new Section (){
                            new RadioElement ("New York City"),
                            new RadioElement ("San Francisco"),
                            new RadioElement ("Dallas"), 
                        }
                    }  , 
                }  ,
                new Section (){
                    new RootElement ("Products") {
                            from sh in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 
                                select new Section (sh + " - Section") {
                                   from filler in "12345" 
                                    select (Element) new CheckboxElement (sh + " - " + filler, true, "kb")
                            }

                    }  , 
                }  

        }  ;        
    }

1 Answers1

1

Every time the TopViewController changes UIPopoverController will attempt to auto-negotiate it's ContentSize.

You should set the ContentSizeForViewInPopover for each UIViewController being presented by overriding the WillShowViewController method and setting the SizeF there.

Anuj
  • 3,134
  • 13
  • 17
  • Thank you, Anuj, for the push in the right direction. I ended up setting up a delegate for my UINavigationController that had the override for the WillShowViewController... worked like a champ! (I could even use a switch on the view controllers to set heights per view controller) Thanks!! – Brad Thornhill Feb 07 '12 at 20:29
  • Awesome, glad that helped. That actually sounds like a good candidate for a .NET eventification in lieu of delegate method override. Feel free to mark as answer if that achieved the desired behavior :-) – Anuj Feb 07 '12 at 20:41