弹出窗口中的导航控制器

发布于 2024-10-19 15:42:58 字数 165 浏览 1 评论 0原文

我是 iPad 应用程序开发的新手。

我有兴趣创建一个应用程序,其中有一个弹出窗口,显示带有项目列表的表格视图。然后我选择一个项目,视图钻取到另一个表格视图,其中包含另一个项目列表和一个导航后退按钮。

我要深入的层次是动态的。

请指导我提供适当的资源来帮助我解决问题。

I am a total newbie in the ipad app development.

I am interested in creating an application where i have a popover showing a tableview with list of items. Then i select an item and the view drills to another tableview consisting of another list of items and a navigate back button as well.

the level to which i would be drilling down is dynamic.

Please guide me with appropriate resources to help me solve the problem.

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

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

发布评论

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

评论(3

╰沐子 2024-10-26 15:42:58

我以前做过并且效果很好!
只需将此函数分配给您的按钮(可能是 UIBarButtonItem):

UIPopoverController *popover;
bool isPopoverOpen = false;
-(void)openPopover{
    if(!isPopoverOpen){
        FirstViewController *firstViewCtrl = [[PartsViewCtrl alloc] init];
        UINavigationController *navbar = [[UINavigationController alloc] initWithRootViewController:firstViewCtrl];
        [firstViewCtrl release];
        navbar.contentSizeForViewInPopover = CGSizeMake(TABLE_WIDTH, TABLE_HEIGHT);
        popover = [[UIPopoverController alloc] initWithContentViewController:navbar];
        [navbar release];
        popover.delegate = self;
        popover.popoverContentSize = CGSizeMake(TABLE_WIDTH, TABLE_HEIGHT);
        [popoverOnPartsView presentPopoverFromBarButtonItem:barButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        isPopoverOpen = true;
    }else{
        [popover dismissPopoverAnimated:YES];
        [popover release];
        isPopoverOpen = false;
    }
}

并将此函数实现到具有 UITableView 的 FirstViewController:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    SecondViewController *secondViewController = [[SecondViewController alloc] init];
    [self.navigationController pushViewController:secondViewController animated:YES];
    [secondViewController release];
}

现在您也可以将 UITableView 添加到 SecondViewController。并将此场景用于其他表!

我希望它对你有用!

I did it before and it works well!
Just assign this function to your button (perhaps an UIBarButtonItem):

UIPopoverController *popover;
bool isPopoverOpen = false;
-(void)openPopover{
    if(!isPopoverOpen){
        FirstViewController *firstViewCtrl = [[PartsViewCtrl alloc] init];
        UINavigationController *navbar = [[UINavigationController alloc] initWithRootViewController:firstViewCtrl];
        [firstViewCtrl release];
        navbar.contentSizeForViewInPopover = CGSizeMake(TABLE_WIDTH, TABLE_HEIGHT);
        popover = [[UIPopoverController alloc] initWithContentViewController:navbar];
        [navbar release];
        popover.delegate = self;
        popover.popoverContentSize = CGSizeMake(TABLE_WIDTH, TABLE_HEIGHT);
        [popoverOnPartsView presentPopoverFromBarButtonItem:barButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        isPopoverOpen = true;
    }else{
        [popover dismissPopoverAnimated:YES];
        [popover release];
        isPopoverOpen = false;
    }
}

And implement this function to FirstViewController which has an UITableView:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    SecondViewController *secondViewController = [[SecondViewController alloc] init];
    [self.navigationController pushViewController:secondViewController animated:YES];
    [secondViewController release];
}

Now you can add an UITableView to SecondViewController, Too. And use this scenario for other tables!

I hope it works for you!

冰火雁神 2024-10-26 15:42:58

创建弹出窗口时,只需分配一个 UINavigationController 并使用它来管理弹出窗口本身内的视图层次结构。快速网络搜索发现了本教程,其中涵盖了您需要的内容知道。

我还想补充一点,您应该总体上熟悉 Objective-C 和 iOS 开发。不要尝试盲目地使用您在网上找到的东西而不了解您实际在做什么:)

When you create the popover, you just need to allocate a UINavigationController and use this to manage the view hierarchy within the popover itself. A quick web search revealed this tutorial which covers the things you need to know.

I also meant to add that you should get up to speed with Objective-C and iOS development in general. Don't try and blindly use things you've found on the net without understanding what you're actually doing :)

友谊不毕业 2024-10-26 15:42:58
Do the following steps 

1)在按钮的操作中(通过单击该按钮,弹出窗口应该出现)编写代码

[这里 PopOverContentViewController 是一个 viewController,其中我有表格视图和几个在弹出窗口到达时应该显示的项目列表] 2

 - (IBAction)callPopOver:(id)sender 
  {


    UIButton *button = (UIButton*)sender;
    PopOverContentViewController1 *popOverContent = [[PopOverContentViewController1     alloc]initWithNibName:@"PopOverContentViewController1" bundle:nil];

    UINavigationController *navbar = [[UINavigationController alloc]  initWithRootViewController:popOverContent];

    navbar.contentSizeForViewInPopover = CGSizeMake(266, 200);
    popover = [[UIPopoverController alloc] initWithContentViewController:navbar];
    popover.delegate = self;
    [popover presentPopoverFromRect:CGRectMake(button.frame.size.width / 2,   button.frame.size.height / 1, 1, 1) inView:button   permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [popover setPopoverContentSize:CGSizeMake(266, 200) animated:YES]; 
    [popUpContent release];


    }      

)现在要在单击任何行时更改表格视图,请在 PopOverViewController.m 中键入此代码

[此处 PopOverViewController2 是我们要显示下一个表格视图的 ViewController]

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    PopOverViewController2 *secondViewController = [[PopOverViewController2 alloc] init];
    [self.navigationController pushViewController:secondViewController animated:YES];
    [secondViewController release];
    }

3)为了避免导航时弹出窗口大小发生变化,请在两个视图控制器(即 PopOverContentViewController1 和 PopOverContentViewController2)的 viewDidLoad 中编写以下代码

 - (void)viewDidLoad
 {
  [super viewDidLoad];
  [self setContentSizeForViewInPopover:CGSizeMake(266, 200)];
 }
Do the following steps 

1)In the action of button (by clicking on that button pop over should appear) write the code

[here PopOverContentViewController is a viewController where i have table view and several list of items which should be displayed when the pop over arrives]

 - (IBAction)callPopOver:(id)sender 
  {


    UIButton *button = (UIButton*)sender;
    PopOverContentViewController1 *popOverContent = [[PopOverContentViewController1     alloc]initWithNibName:@"PopOverContentViewController1" bundle:nil];

    UINavigationController *navbar = [[UINavigationController alloc]  initWithRootViewController:popOverContent];

    navbar.contentSizeForViewInPopover = CGSizeMake(266, 200);
    popover = [[UIPopoverController alloc] initWithContentViewController:navbar];
    popover.delegate = self;
    [popover presentPopoverFromRect:CGRectMake(button.frame.size.width / 2,   button.frame.size.height / 1, 1, 1) inView:button   permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [popover setPopoverContentSize:CGSizeMake(266, 200) animated:YES]; 
    [popUpContent release];


    }      

2)now to change the table view on clicking on any of the rows type this code in PopOverViewController.m

[here PopOverViewController2 is the ViewController where we have the next table view to be displayed]

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    PopOverViewController2 *secondViewController = [[PopOverViewController2 alloc] init];
    [self.navigationController pushViewController:secondViewController animated:YES];
    [secondViewController release];
    }

3)to avoid the change in size of popover while navigation write the following code in viewDidLoad of both view controllers (ie PopOverContentViewController1 and PopOverContentViewController2)

 - (void)viewDidLoad
 {
  [super viewDidLoad];
  [self setContentSizeForViewInPopover:CGSizeMake(266, 200)];
 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文