导航控制器在popover [英] Navigation Controller in popover

查看:144
本文介绍了导航控制器在popover的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是ipad应用程序开发中的一个新手。



我有兴趣创建一个应用程序,其中我有一个popover显示一个列表的项目。然后,我选择一个项目,并且视图演练到另一个表视图,包括另一个项目列表和导航返回按钮。



我将向下钻取的级别是动态的。



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

解决方案

我以前做过,效果很好!
只需将此函数分配给您的按钮(可能是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 allowedArrowDirections: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,Too。并将其用于其他表格!



我希望它适用于您!


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.

解决方案

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!

这篇关于导航控制器在popover的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆