【发布时间】:2012-03-14 11:32:33
【问题描述】:
我的弹出框显示有问题。在initWithContentViewController: 和presentPopoverFromBarButtonItem:permittedArrowDirections:animated: 之后,它会切入导航栏的角落。我该怎么修??谢谢。
这是我正在使用的代码
NavContr *nav = [NavContr new];
nav.navigationBar.backgroundColor = [UIColor redColor];
UIPopoverController *tempPop = [[UIPopoverController alloc] initWithContentViewController:nav];
[tempPop presentPopoverFromBarButtonItem:mainButtonItem permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO];
编辑:我已经解决了这个问题:
+ (void)configure:(UINavigationController *)navController {
UINavigationBar *navigationBar = navController.navigationBar;
UIView *contentView = nil;
for (UIView *view in navController.view.subviews) {
if ([[NSString stringWithFormat:@"%@", [view class]] isEqualToString:@"UILayoutContainerView"])
contentView = view;
}
// setting frame to navigation bar and content view
[navigationBar setFrame:CGRectMake(navigationBar.frame.origin.x, 0, navigationBar.frame.size.width, navigationBar.frame.size.height)];
[contentView setFrame:CGRectMake(contentView.frame.origin.x, 0, contentView.frame.size.width, contentView.frame.size.height + navigationBar.frame.size.height)];
[navController.view bringSubviewToFront:contentView];
for (UIView *customView in contentView.subviews)
customView.frame = CGRectMake(customView.frame.origin.x, customView.frame.origin.y + navigationBar.frame.size.height, customView.frame.size.width, customView.frame.size.height);
[contentView addSubview:navigationBar];
[contentView bringSubviewToFront:navigationBar];
}
【问题讨论】:
-
请给出生成UIPopoverController的完整代码
-
尝试添加一些 viewController 到你的导航控制器
-
您无法更改此功能。可能有一些未记录的方法可以做到这一点,但实施它很可能会导致您的应用被 Apple 拒绝。
-
@LastNight 您的问题将得到解决,请查看我在此页面中的回答。我在最后复制了你的场景并得出了结论。看看@我的回答。
-
试试这个stackoverflow.com/questions/12440250/… 它对我有用。
标签: iphone objective-c uinavigationcontroller uipopovercontroller