Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to present UIView without UIViewController in UIPopoverController?

Is it possible to quickly present a UIView in a UIPopoverController without having a UIViewController managing the UIView?

Currently I have a "DelegateViewController" that gets my view passed. Then I use that controller for presentation. But I'm wondering if there is an easier way?

like image 826
Krumelur Avatar asked Feb 22 '12 13:02

Krumelur


2 Answers

If you have a UIView, then you can easily create a plain UIViewController as a container.

UIViewController* controller = [[[UIViewController alloc] init] autorelease];
controller.view = myView;
like image 50
bendytree Avatar answered Nov 04 '22 19:11

bendytree


Is it possible to quickly present a UIView in a UIPopoverController without having a UIViewController managing the UIView?

No. UIPopoverController manages a view controller, not a view. When you create a popover controller, you have to provide the view controller that will manage the content. That doesn't mean that you have to create a special view controller subclass in every place where you use a popover -- as bendytree points out, you can use a plain old UIViewController if you want. But you can't just pass UIPopoverController a view -- it has no way to accept it, and wouldn't know what to do with it if did.

like image 28
Caleb Avatar answered Nov 04 '22 21:11

Caleb