Q:

UIPopovercontroller not showing properly

I need to show a simple popover view in which a navigation bar with a done button and a picker view is to be shown.  i am doing everything programmatically and code is shown below. 
CGRect displayFrame = CGRectMake(0, 0, 300.0f,500.0f);
//((CGFloat)[self.pocModelData.arrayOfDistricts count] + 25)

UIView *popoverView = [[UIView alloc] initWithFrame:displayFrame];
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0,0,popoverView.frame.size.width,20)];

UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle:@"some title"];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissPopoverAnimated:)];
navItem.rightBarButtonItem = doneButton;
navBar.items = [NSArray arrayWithObjects:navItem, nil];

[popoverView addSubview:navBar];

CGRect displayFramePopOver = CGRectMake(0, 0, 600.0f,((CGFloat)[self.pocModelData.arrayOfDistricts count] - 25));

UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:displayFramePopOver];
[popoverView addSubview:pickerView];

UIViewController *tvc = [[UIViewController alloc] init];
//tvc.view = popoverView;
[tvc setView:popoverView];
self.popvc = [[UIPopoverController alloc] initWithContentViewController:tvc];
self.popvc.delegate = self;

//[popvc setPopoverContentSize:CGSizeMake(400, 200)];
[self.popvc presentPopoverFromRect: anchor.frame inView: anchor.superview permittedArrowDirections: UIPopoverArrowDirectionAny animated: YES];

Unfortunately since i dont have a reputation of 10, i cant post the result of the execution of code, so i will try to explain what is shown.  Popover is shown but with a view which has a black rectangle shown over what seems to be the navy blue background. What i am seeking is how to figure out setting the size of the view and popover correctly, so that it shows proper popover with a navigation bar and a uipickerview.  

A:

You are going through this in quite an odd way.  Here is what you should do.  Instead of making your own navigation bar, just use the one that comes with UINavigationController.  
1.)  create a navigationController, call it navC
2.)  create a viewController, call it vC
3.)  create a pickerView, call it pV  
4.)  set vC up with navigation bars and such using property self.navigationItem.rightBarButtonItem
5.)  insert pV into vC -> [vC.view addSubview:pV]
6.)  insert vC into navC -> navC.rootViewController = vC 
7.)  insert navC into the popOver -> self.popvc = [[UIPopoverController alloc] initWithContentViewController:navC];
8.)  present the view.  
Profit. ( P.S. Do not name your variable like that.  name it long and descriptive)

