Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6747941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:30:21+00:00 2026-05-26T12:30:21+00:00

I made a popover class that I could call easily for basic popovers –

  • 0

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.

This was working fine until iOS5, now the popover opens but with just the border, no white space or content at all.

I’ve searched and searched, any ideas you could throw my way would be great.

@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<BasicPickerDelegate> 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<BasicPickerDelegate> delegate;

 - (void)setSize;
 - (void)checkData;

@end

Then the setSize function is viewDidLoad

- (void)setSize {

    if (!myWidth || !myHeight) {

      NSLog(@"WIDTH AND HEIGHT NOT SET, SETTING DEFAULTS");
      myWidth = 100;
      myHeight = 100;

    }

    self.contentSizeForViewInPopover = CGSizeMake(myWidth, myHeight);
}

Then I call it like this:

- (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];

}

When I run it, the WIDTH AND HEIGHT NOT SET, SETTIN DEFAULTS 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.

edit: So basically:

With setSize being called in viewDidLoad it doesn’t know what the width and height is. So it sets the default.

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.

When setSize is called in viewWillAppear, viewDidAppear or anything like that (after viewDidLoad) it doesn’t actually set the size of the popover.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:30:22+00:00Added an answer on May 26, 2026 at 12:30 pm

    Finally figured this out.

    I needed to assign the width/height variables after creating the popover but before initialising it.

    Revised code below:

    self.basicPicker = [[[BasicPickerController alloc] initWithStyle:UITableViewStylePlain] autorelease];
    
    // Give popover the data it needs
    
    basicPicker.delegate = self;
    
    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];
    
    // Now init
    
    self.basicPickerPopover = [[[UIPopoverController alloc] 
                                initWithContentViewController:basicPicker] autorelease];      
    
    [basicPicker viewDidLoad];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a class that derives from Component: public class MyComponent: System.ComponentModel.Component { }
Made solution change: I am trying to display a html table of data.. In
I made a class from Linq to SQL Clasees with VS 2008 SP1 Framework
I made a code that translate strings to match each word from the array
I made a UIView using Interface Builder with a top bar that has Cancel
I made a plist that looks like that: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC
I made a UITableViewCell subclass, and now I want that subclass to be clever.
Made a fiddle for this: http://jsfiddle.net/terjeto/MN4FJ/ My problem is that dragleave fires when you
Made a simple script that hide/show a hidden div. The page automatically adjusts its
I made a class for DB connection like this: public class DbHelper : IDisposable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.