Note that there are some explanatory texts on larger screens.

plurals
  1. POPopover with no size
    primarykey
    data
    text
    <p>I made a popover class that I could call easily for basic popovers - you give it data and set the size and it should do the rest. </p> <p>This was working fine until iOS5, now the popover opens but with just the border, no white space or content at all.</p> <p>I've searched and searched, any ideas you could throw my way would be great.</p> <pre><code>@protocol BasicPickerDelegate - (void)basicPickerItemSelected:(NSMutableDictionary *)thisDic; @end @interface BasicPickerController : UITableViewController { // data IBOutlet NSMutableArray *theData; // stuff to set IBOutlet int myWidth; IBOutlet int myHeight; IBOutlet int myPopoverNum; // delegate id&lt;BasicPickerDelegate&gt; delegate; } @property (nonatomic, retain) IBOutlet NSMutableArray *theData; @property (nonatomic, assign) IBOutlet int myWidth; @property (nonatomic, assign) IBOutlet int myHeight; @property (nonatomic, assign) IBOutlet int myPopoverNum; @property (nonatomic, assign) id&lt;BasicPickerDelegate&gt; delegate; - (void)setSize; - (void)checkData; @end </code></pre> <p>Then the setSize function is viewDidLoad</p> <pre><code>- (void)setSize { if (!myWidth || !myHeight) { NSLog(@"WIDTH AND HEIGHT NOT SET, SETTING DEFAULTS"); myWidth = 100; myHeight = 100; } self.contentSizeForViewInPopover = CGSizeMake(myWidth, myHeight); } </code></pre> <p>Then I call it like this:</p> <pre><code>- (IBAction)showBasicPopover:(id)sender { // Show Basic Popover - can be reused if (basicPicker != nil) { self.basicPicker = nil; [self.basicPicker release]; } self.basicPicker = [[[BasicPickerController alloc] initWithStyle:UITableViewStylePlain] autorelease]; basicPicker.delegate = self; self.basicPickerPopover = [[[UIPopoverController alloc] initWithContentViewController:basicPicker] autorelease]; // Give popover the data it needs NSMutableDictionary *sizeDic = [self returnPopoverSize:[sender tag]]; self.basicPicker.myHeight = [[sizeDic objectForKey:@"height"] intValue]; self.basicPicker.myWidth = [[sizeDic objectForKey:@"width"] intValue]; self.basicPicker.myPopoverNum = [sender tag]; [basicPicker viewDidLoad]; self.basicPicker.theData = [self returnPopoverData:[sender tag]]; NSLog(@"giving popover dic (%d) with %d derps", [sender tag], [self.basicPicker.theData count]); // Set display settings and show popover [basicPicker viewWillAppear:YES]; CGRect popoverRect = [self.view convertRect:[sender frame] fromView:[sender superview]]; [self.basicPickerPopover presentPopoverFromRect:popoverRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } </code></pre> <p>When I run it, the <code>WIDTH AND HEIGHT NOT SET, SETTIN DEFAULTS</code> dialogue comes up. For some reason it's not reading in the values it's given. Though with some fiddling, even if I can get it to read them in it don't think they are valid and overrides them.</p> <p><strong>edit:</strong> So basically:</p> <p>With setSize being called in viewDidLoad it doesn't know what the width and height is. So it sets the default.</p> <p>If setSize isn't called in viewDidLoad, it comes up with "no size" - ie it has popover border but no content in it at all.</p> <p>When setSize is called in viewWillAppear, viewDidAppear or anything like that (after viewDidLoad) it doesn't actually set the size of the popover.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload