UIPopoverController与UINavigationController边界大小调整

时间:2013-03-18 02:17:23

标签: ios uinavigationcontroller uipopovercontroller

我在UIPopoverController中嵌入了UINavigationController。它“工作”,但弹出窗口的顶部边框扩展到导航控制器栏的大小(在它后面),将边框的阴影投射到主视图的顶部(读取:弹出窗口的顶部边框高44点) )。当我使用类本身实例化弹出窗口时...不在UINavigationController中,它一切正常(但是,当然我无法访问导航控制器)。

我哪里错了?

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];

2 个答案:

答案 0 :(得分:0)

你所看到的并不是扩展的popover的顶部边界。 popover有正常的边框。你看到的是导航控制器视图顶部的UINavigationBar。 UINavigationBar在iOS 6中投下阴影。

UINavigationBar会自动获得与弹出边框匹配的特殊颜色/样式。当然,如果你不喜欢它,你可以改变它。如果您不想看到它,也可以隐藏导航控制器的导航栏。

答案 1 :(得分:0)

继承了UIPopoverController的子类,但是没有获得popover的光泽外观。只需将UINavigationController放在UIViewController中......即可获得自定义导航栏和弹出窗口的光泽外观。这就是我最终的结果:

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];