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.