Is it possible to imagine a UIView without a UIViewController in a UIPopoverController?

Is it possible to quickly imagine a UIView in a UIPopoverController without having the UIViewController controlling the UIView ?

I currently have a " DelegateViewController " that conveys my view. Then I use this controller for presentation. But I wonder if there is an easier way?

+7
source share
3 answers

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

 UIViewController* controller = [[[UIViewController alloc] init] autorelease]; controller.view = myView; 
+13
source

Is it possible to quickly represent a UIView in a UIPopoverController without controlling the UIViewController UIView?

Not. The UIPopoverController controls the view controller, not the view. When you create a popover controller, you must provide a view controller that will control the content. This does not mean that you need to create a special subclass of the view class in all places where you use popover - as bendytree points out, you can use the plain old UIViewController if you want. But you can’t just pass the UIPopoverController view - it doesn’t have the ability to accept it and did not know what to do with it if it did.

+1
source

It usually makes sense to have a UIViewController for the view, as the controller handles all the interaction and setting up the view. Although in some situations you can put bare views on the screen, the UIPopoverController designed to work with the UIViewController , and the ViewController paradigm has worked very well and has been encouraged in the iOS world, so even if you think you don’t know, it looks like you need a view controller It should not be harmful to its use, and you can always expand the current functionality, right?

Please note: if you are running iOS 5.0, creating views in Popovers is very simple and requires dragging view controllers and connecting them to the storyboard. Example: How to create Xcode Popovers

0
source

All Articles