sol
sol

Reputation: 6462

UITableView width when inside a popover

See below - the tableView cells are getting cut off. Why doesn't this work? The width of the popover is 240.

(In a subclass of UITableViewController)

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tableView.frame = CGRectMake(0,0,200,200);
}

alt text

Upvotes: 0

Views: 1913

Answers (2)

Joshua
Joshua

Reputation: 1

Have you tried specifying the popover's content size?

i.e.

self.popoverController.popoverContentSize = CGSizeMake(400, 500);

I've found that while popover's are "suppose" to adjust to the appropriate size based on the content view controller, this doesn't always work as well as it should.

Upvotes: 0

tiguero
tiguero

Reputation: 11537

You have to specify the content size of the ui controller you are displaying. You can do it in 2 ways:

  • access the ui controller from your popover controller and set it size:
UIViewController* yourViewController = yourPopOverController.contentViewController;
yourViewController.contentSizeInViewController = CGSizeMake(300, 600);
  • check the checkbox "Use Explicit Size" for popover in the inspector of the viewController in storyboard

As you see the content ui controller is the one responsible of setting the size of your popover.

Upvotes: 1

Related Questions