在UIPopoverController中导航 [英] Navigation inside a UIPopoverController

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

问题描述

我有一个 UIPopoverController ,它由表视图组成。这个弹出控制器显示得很好,我已经设置了委托 didSelectRowAtIndexPath 就好了。

I have a UIPopoverController that consist of table view. This pop over controller displayed well, and I already set the delegate didSelectRowAtIndexPath just fine.

现在,我想基于点击的表格项目进入详细视图控制器。然后在目标视图上,它有一个后退按钮,如 pushViewController ,但它不能正常工作。它不会导航到详细视图控制器。这是我的 didSelectRowAtIndexPath

Right now, I want to make some transition into "detail view controller" based on table item clicked. Then on destination view, it has back button like a pushViewController but it doesn't work well. It wont navigate into detail view Controller. This is my didSelectRowAtIndexPath:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    DetailSummaryViewController *detailVC = [[DetailSummaryViewController alloc] initWithNibName:@"DetailSummaryViewController" bundle:nil];
    [self.navigationController pushViewController:detailVC animated:YES];
}

这是我的popupover方法

This is my popupover method

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    CalendarCell *cell = (CalendarCell *)[collectionView cellForItemAtIndexPath:indexPath];

    UIPopoverController *popC = [[UIPopoverController alloc] initWithContentViewController:[SummaryViewController new]];
    [popC setPopoverContentSize:CGSizeMake(320, 400)];
    [self setPop:popC];

    [[self pop] presentPopoverFromRect:[cell frame]
                                inView:collectionView
              permittedArrowDirections:UIPopoverArrowDirectionAny
                              animated:YES];
}

那些导航无法正常工作,但是如果我NSLog-ing选择索引它很好用。是否有一些设置导航的步骤我错过了?

Those navigation wont work, but if I NSLog-ing selected index it works nicely. Is there some step at setting up navigation that I am missed?

推荐答案

你没有导航控制器在你的popover控制器中,所以方法 self.navigationController pushViewController 不会工作。请尝试以下方法:

You donot have a Navigation Controller in your popover controller, so the method self.navigationController pushViewController wont work. Try this below:

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    CalendarCell *cell = (CalendarCell *)[collectionView cellForItemAtIndexPath:indexPath];

    UINavigationController *insidePopoverNavigationController = [[UINavigationController alloc] initWithRootViewController:[SummaryViewController new]];

    UIPopoverController *popC = [[UIPopoverController alloc] initWithContentViewController:insidePopoverNavigationController];
    [popC setPopoverContentSize:CGSizeMake(320, 400)];
    [self setPop:popC];

    [[self pop] presentPopoverFromRect:[cell frame]
                                inView:collectionView
              permittedArrowDirections:UIPopoverArrowDirectionAny
                              animated:YES];
}

其他积分:Raica Dumitru Cristian

Additional Credits: Raica Dumitru Cristian

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

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