UIPopover 中的导航栏

发布于 2024-10-17 08:37:37 字数 921 浏览 3 评论 0 原文

在我的 splitviewcontroller iPad 应用程序中,我显示了一个自定义弹出窗口(它加载 rootviewController)。如何不仅显示表视图,还显示其顶部的导航栏(以显示表标题“类别”)。

这是我的应用程序:

在此处输入图像描述

我显示弹出窗口的代码:

- (IBAction)showPopover:(UIButton *)sender {
if([self.popoverController isPopoverVisible])
{
    [self.popoverController dismissPopoverAnimated:YES];
    return;
}

// Build a custom popover view
TemplatesAppDelegate *delegate = (TemplatesAppDelegate*)[[UIApplication sharedApplication] delegate];

// Create a popover controller
self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:delegate.rootViewController] autorelease];

// Present the popover view non-modal at the pressed button's position
[self.popoverController presentPopoverFromRect:sender.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}

in my splitviewcontroller iPad app I show a custom popover (which loads the rootviewController). How to show not only the table view, but also a navigationbar on top of it (to show the table title "Categories").

Here is my app:

enter image description here

My code to show the popover:

- (IBAction)showPopover:(UIButton *)sender {
if([self.popoverController isPopoverVisible])
{
    [self.popoverController dismissPopoverAnimated:YES];
    return;
}

// Build a custom popover view
TemplatesAppDelegate *delegate = (TemplatesAppDelegate*)[[UIApplication sharedApplication] delegate];

// Create a popover controller
self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:delegate.rootViewController] autorelease];

// Present the popover view non-modal at the pressed button's position
[self.popoverController presentPopoverFromRect:sender.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回心转意 2024-10-24 08:37:37

如果你想要一个具有所有功能的整个 UINavigationController,你可以这样做

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:delegate.rootViewController];

self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:navController] autorelease];
[navController release];

,或者如果你只想要一个导航栏,你可以添加到你的 popovercontroller 中。

UINavigationBar *tableViewNavigationBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)];
[self.popoverController addSubView:tableViewNavigationBar];

我没有测试代码,但它应该可以工作。

If you want a whole UINavigationController with all the functionalities, you can do like

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:delegate.rootViewController];

self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:navController] autorelease];
[navController release];

Or if you want just a navigation bar you can add to your popovercontroller.

UINavigationBar *tableViewNavigationBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)];
[self.popoverController addSubView:tableViewNavigationBar];

I didn't tested the code, but it should work.

回忆那么伤 2024-10-24 08:37:37

你可以试试这个:

CNYAssetTypeViewController *avc=[[CNYAssetTypeViewController alloc] init];
if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad){
    UINavigatinoController *nv=[[UINavigationController alloc]initWithRootViewController:avc];
    self.assetTypeControllerPopover=[[UIPopOverController alloc]initWithContentViewController:nv];
    self.assetTypeControllerPopover.delegat=self;
    avc.title=@"CNY";
    [self.assetTypeControllerPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopOverArrowDirectionAny animated:YES];
}else{
    [self.navigationController pushViewController:avc animated:YES];    
}

You could try this:

CNYAssetTypeViewController *avc=[[CNYAssetTypeViewController alloc] init];
if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad){
    UINavigatinoController *nv=[[UINavigationController alloc]initWithRootViewController:avc];
    self.assetTypeControllerPopover=[[UIPopOverController alloc]initWithContentViewController:nv];
    self.assetTypeControllerPopover.delegat=self;
    avc.title=@"CNY";
    [self.assetTypeControllerPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopOverArrowDirectionAny animated:YES];
}else{
    [self.navigationController pushViewController:avc animated:YES];    
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文