我的彈窗顯示有問題。在initWithContentViewController:
和presentPopoverFromBarButtonItem:permittedArrowDirections:animated:
之後,它會切割導航欄的邊角。我應該如何解決?謝謝。UIPopoverController和UINavigationController削減角落
這是我使用的代碼
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 – Injectios 2012-03-14 11:43:59
嘗試一些的viewController添加到您的導航控制器 – Injectios 2012-03-14 11:53:56
您不能更改此功能。可能有一些無證的方法可以實現,但實施它可能會讓您的應用被Apple拒絕。 – RLH 2012-03-21 20:27:13