0

I am embedding a UINavigationController within a UIPopoverController. It "works", but the top border of the popover expands to the size of the navigation controller bar (behind it), casting the border's shadow onto the top of the main view (read: the top border of the popover is 44 points high). When I instantiate the popover with the class itself...not within the UINavigationController, it all works fine (but, of course I don't have access to the navigational controller).

Where am I going wrong?

CGPoint buttonPoint = [self.mapView convertPoint:sender.center fromView:self.guideButtonScroll];

GuideViewController *guideViewController = [[GuideViewController alloc] initWithNibName:@"GuideView" bundle:nil];

UINavigationController *guideNavigationController = [[UINavigationController alloc] initWithRootViewController:guideViewController];

self.buttonbarPopoverController = [[UIPopoverController alloc] initWithContentViewController:guideNavigationController];
self.buttonbarPopoverController.delegate = self;
self.buttonbarPopoverController.popoverContentSize = CGSizeMake(320, 504);
[self.buttonbarPopoverController presentPopoverFromRect:CGRectMake(buttonPoint.x - 30, buttonPoint.y, 10, 10) inView:self.mapView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
4

2 回答 2

0

What you are seeing is not the top border of the popover expanded. The popover has normal borders. What you are seeing is the UINavigationBar at the top of the navigation controller's view. The UINavigationBar casts a shadow in iOS 6.

The UINavigationBar is automatically given a special color / style that matches that of the popover borders. Of course you can change that if you don't like it. You are also free to hide the navigation controller's navigation bar if you don't want to see it.

于 2013-03-18T02:49:37.973 回答
0

Went with subclassing the UIPopoverController, but that didn't get the gloss look of the popover. Simply just put the UINavigationController inside a UIViewController...gets the custom navigation bar and the gloss look of the popover. Here's what I ended up with:

UIViewController *guideviewViewController = [[UIViewController alloc] init];
guideviewViewController.view.frame = CGRectMake(0, 0, 320, 508);

GuideViewController *guideViewController = [[GuideViewController alloc] initWithNibName:@"GuideView" bundle:nil];

self.guideNavigationController = [[UINavigationController alloc] initWithRootViewController:guideViewController];
self.guideNavigationController.view.frame = CGRectMake(0, 0, 320, 508);

[guideviewViewController.view addSubview:self.guideNavigationController.view];

CGPoint buttonPoint = [self.mapView convertPoint:sender.center fromView:self.guideButtonScroll];

self.guidePopoverController = [[UIPopoverController alloc] initWithContentViewController:guideviewViewController];
self.guidePopoverController.delegate = self;
self.guidePopoverController.popoverContentSize = CGSizeMake(320, 508);
[self.guidePopoverController presentPopoverFromRect:CGRectMake(buttonPoint.x - 30, buttonPoint.y, 10, 10) inView:self.mapView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
于 2013-03-19T00:07:16.853 回答