Reputation: 135
I'm using a popover that should simply show a UIView inside. But although the popup shows up, it contains only an empty view (that is colored in some kind of dark blue). The UIViewController is use is the "PreferencesController" in there.
My Code to open the popup is the following:
- (IBAction)showPopup:(id)sender {
if (_preferencesController == nil) {
self.preferencesController = [[PreferencesController alloc]init];
self.preferencesControllerPopover = [[UIPopoverController alloc]
initWithContentViewController:_preferencesController];
}
[self.preferencesControllerPopover presentPopoverFromBarButtonItem:sender
permittedArrowDirections:0 animated:YES];
}
Besides that I only have the "preferencesController" that doesn't include any special methods besides the viewDidLoad
with "self.contentSizeForViewInPopover = CGSizeMake(800.0, 800.0);
"
This is what I get:
Any ideas why it isn't working properly?
Upvotes: 1
Views: 279
Reputation: 2805
800.0 width is too large for a Popover to handle.
In the documentation for UIViewController:
(Discussing contentSizeForViewInPopover
)
This property contains the desired size for the view controller when it is displayed in a popover. By default, the width is set to 320 points and the height is set to 1100 points. You can change these values as needed.
The recommended width for popovers is 320 points. If needed, you can return a width value as large as 600 points, but doing so is not recommended.
Try presenting your UIViewController modally by calling presentModalViewController:animated:
from the UIViewController you want the modal view controller to animate on top of.
Upvotes: 2
Reputation: 107121
I think this code makes the issue:
[self.preferencesControllerPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:0 animated:YES];
Because sender is of type id, so you need to cast it, Like:
UIBarButtonItem *but = (UIBarButtonItem *)sender;
[self.preferencesControllerPopover presentPopoverFromBarButtonItem:but permittedArrowDirections:0 animated:YES];
Hope it'll solve the issue.
Upvotes: 0