Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to set popover size?

Tags:

I have a UIViewController called HomeViewController and it has a model that contains an array of data. HomeViewController also has a button that when pressed will show a UITableViewController that display's the model's array of data.

My question is, what is the standard/best way to set the popover's size? I only want the popover to be tall enough to display the data, but no taller. What is common practice? I assume that I need to set contentSizeForViewInPopover at some point but I'm not sure where...In the viewDidLoad method of the popover class? In the prepareForSegue method?

Here's the code I have so far: (Note that DataPresentingViewController is my popover view controller class`)

//In HomeViewController
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([segue.destinationViewController isKindOfClass:[DataPresentingViewController class]])
    {
        DataPresentingViewController *dest = (DataPresentingViewController *) segue.destinationViewController;
        dest.mySavedData = self.myModel.mySavedData;
    }
}

I know that I could just set the contentSizeForViewInPopover here in the prepareForSegue method; however, this seems like something the popover class should deal with.

like image 512
Nosrettap Avatar asked Aug 06 '12 21:08

Nosrettap


People also ask

How do you set the popover width in material UI?

You can either change the className to style, and it should work or you're going to have to add a const variable and hook it into the withStyle HOC. Then add the height and width to that const, and then call the class you made in that to the className. All these examples are on the material-ui site.

How do you activate popovers?

Popovers can be triggered via JavaScript — just call the popover() Bootstrap method with the id , class or any CSS selector of the required element in your JavaScript code. You can either initialize popovers individually or all in one go.

How do you show popovers?

How To Create a Popover. To create a popover, add the data-toggle="popover" attribute to an element. Note: Popovers must be initialized with jQuery: select the specified element and call the popover() method.


2 Answers

As of iOS7 contentSizeForViewInPopover is deprecated. You should use UIViewController's preferredContentSize property instead.

Hope this helps!

like image 188
LuisCien Avatar answered Sep 28 '22 21:09

LuisCien


set contentSizeForViewInPopover in ViewDidLoad method in HomeViewController

like image 28
Azat Avatar answered Sep 28 '22 22:09

Azat