UIPopoverController以模态方式呈现在iOS 5中不起作用 [英] UIPopoverController presented modally doesn't work in iOS 5

查看:151
本文介绍了UIPopoverController以模态方式呈现在iOS 5中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我们可以在这谈谈iOS 5吗?或者它仍然在NDA下?
如果我们不能谈论它,请忽略我的问题。

First of all, can we talk about iOS 5 here? Or is it still under NDA? If we can't talk about it, just ignore my question.

通过安装iOS 5的iPad测试我的应用程序我发现我的问题模态弹出:这可以通过点击它来关闭,换句话说,它不是模态!我不知道我做错了什么。

By testing my app with an iPad with iOS 5 installed I discovered a problem with my "modal" popover: This can be closed by tapping outside of it, in other words, it's not modal! I have no idea what I'm doing wrong.

视图控制器使用以下代码打开popover:

A view controller opens the popover with this code:

AddProjectViewController *addProjectViewController = [[AddProjectViewController alloc] initWithStyle:UITableViewStyleGrouped];
[addProjectViewController setDelegate:self];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addProjectViewController];
[addProjectViewController release];

CGRect popoverFrame = [sender frame];

UIPopoverController *tempPopover = [[UIPopoverController alloc] initWithContentViewController:navController];
[tempPopover presentPopoverFromRect:popoverFrame inView:[self view] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
self.currentPopover = tempPopover;
[tempPopover release];
[navController release];

popover内部的视图控制器在viewDidLoad中有这一行。

The view controller that's inside of the popover has this line in it's viewDidLoad.

- (void)viewDidLoad
{
    [self setModalInPopover:YES];

    // Do other stuff
}

有没有什么失踪?

推荐答案

我找到了。 setModalInPopover赋值必须位于嵌入式视图控制器的viewDidAppear方法内,以使popover为模态:

I found it. The setModalInPopover assignment must be inside of the viewDidAppear method of the embedded view controller for the popover to be modal:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    [self setModalInPopover:YES];
}

这篇关于UIPopoverController以模态方式呈现在iOS 5中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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