piligreem
piligreem

Reputation: 59

UIPopoverPresentationController from storyboard

I'm initialising my UIPopoverPresentationController from code:

ChoseOptionsViewController *contentController = [[ChoseOptionsViewController alloc] init];
contentController.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *copvc = contentController.popoverPresentationController;
copvc.permittedArrowDirections = UIPopoverArrowDirectionAny;
copvc.sourceView = sender;
copvc.sourceRect = sender.bounds;
contentController.preferredContentSize = CGSizeMake(200, 200);
[self presentViewController:contentController animated:YES completion:nil];

And all I'm getting is an empty 200x200 view, although I've created a ViewController in storyboard, assigned ChoseOptionsViewController class to it and dragged some UI elements. Tell me please, how can I get my view from storyboard when initialising a popover from code. Thanks in advance.

Upvotes: 1

Views: 812

Answers (1)

rdelmar
rdelmar

Reputation: 104092

When you make a view controller in the storyboard, you should create an instance of it with instantiateViewControllerWithIdentifier:, not alloc init.

ChoseOptionsViewController *contentController = [self.storyboard instantiateViewControllerWithIdentifier:@"Whatever"];

Make sure your controller in the storyboard has its identifier set to the same string you pass to the method.

Upvotes: 1

Related Questions