I want to use a UIPopoverController in my application and was trying this example. The problem is that the view and the controller in that example are created from code.
UIViewController* popoverContent = [[UIViewController alloc]
init];
UIView* popoverView = [[UIView alloc]
initWithFrame:CGRectMake(0, 0, 200, 300)];
popoverView.backgroundColor = [UIColor greenColor];
popoverContent.view = popoverView;
I want to use an existing controller with it’s xib file for the popup. How do I link the popup to an existing controller? And do I need to create the controller’s view in some special way for it to match the dimension of the popup?
If you want to use an existing xib, just initialize your viewController using the
nitWithNibName:bundle:method. When you init using the xib your viewController’s view hierarchy will be instantiated for you.Don’t worry about sizing the view when you initialize – the view gets resized in the example code you cite anyway on the next line when the property
contentSizeForViewInPopoveris set.