UIModalPresentationFormSheet,缺少暗淡

发布于 2024-10-18 21:30:44 字数 1267 浏览 7 评论 0原文

我正在尝试使用 UIModalPresentationFormSheet 视图样式在 iPad 应用程序中显示模式 viewController。我希望制作类似于邮件应用程序的新消息 UI/动画的内容。

有两件事表现不正确: 呈现的模态 viewController 始终动画到 y=0,即动画的最顶部 查看而不是像在邮件应用程序中那样位于状态栏下方的一些像素。

文档说:

UIModalPresentationFormSheet 的宽度 所呈现视图的高度和高度是 小于屏幕的尺寸并且 视图位于屏幕中央。如果 设备处于风景状态 方向和键盘是 可见,视图的位置是 向上调整,以便视野 仍然可见。 所有未覆盖区域 变暗以防止用户 与他们互动。

但是,在我的情况下,没有变暗,我仍然可以与 modalViewController 下面的parentView交互。

呈现 modalView 的控制器我这样做:

AddNewItemViewController *newItemViewController = [[AddNewItemViewController alloc] initWithNibName:@"AddNewItemViewController" bundle:nil];
[self presentModalViewController:newItemViewController animated:YES];
[newItemViewController release];

在呈现的 viewController 中我这样做:

- (void)viewDidLoad {

    [nameField becomeFirstResponder];
    [self setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
    [self setModalPresentationStyle:UIModalPresentationFormSheet];
    [super viewDidLoad];
}

我希望有人可以帮助我。

我需要在父级和 modalViewController 上设置一些其他属性吗?

viewDidLoad 不是执行此设置的正确位置吗? >

提前致谢:)

I am trying to display a modal viewController in an iPad app using the UIModalPresentationFormSheet view style. I am looking to produce something similar to the Mail app's new message UI/animation.

There are two things that are not behaving correctly:
The modal viewController that is presented always animates to y=0, i.e. to the very top of the
view and not some pixels below the status bar as it does in the mail app.

The documentation says:

UIModalPresentationFormSheet The width
and height of the presented view are
smaller than those of the screen and
the view is centered on the screen. If
the device is in a landscape
orientation and the keyboard is
visible, the position of the view is
adjusted upward so that the view
remains visible. All uncovered areas
are dimmed to prevent the user from
interacting with them.

However, in my case there is no dimming and I can still interact with the parentView below the modalViewController.

The controller that presents the modalView I do this:

AddNewItemViewController *newItemViewController = [[AddNewItemViewController alloc] initWithNibName:@"AddNewItemViewController" bundle:nil];
[self presentModalViewController:newItemViewController animated:YES];
[newItemViewController release];

In the viewController being presented I do this:

- (void)viewDidLoad {

    [nameField becomeFirstResponder];
    [self setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
    [self setModalPresentationStyle:UIModalPresentationFormSheet];
    [super viewDidLoad];
}

I hope someone can help me out.

Is there some other properties I need to set on the parent and modalViewController?

Is the viewDidLoad not the right place to do this setup?

Thanks in advance:)

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

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

发布评论

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

评论(1

人间不值得 2024-10-25 21:30:44

您可以在创建模态视图时、调用presentModalViewController 之前设置过渡和呈现样式。请记住,创建模态视图的视图“拥有”该对象。您希望所有者设置这些属性,因为您可能在应用程序的其他位置实现此模式视图,并且需要不同的过渡或演示样式。这样,您每次都可以根据需要进行设置。

    AddNewItemViewController *newItemViewController = [[AddNewItemViewController alloc] initWithNibName:@"AddNewItemViewController" bundle:nil];
    newItemViewController.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentModalViewController:newItemViewController animated:YES];
    [newItemViewController release];

你在viewDidLoad中调用becomeFirstResponder是正确的。

You set the transition and presentation styles when you create the modal view, before you call presentModalViewController. Remember, the view that creates the modal view 'owns' that object. You want the owner to set these properties because you might implement this modal view elsewhere in the app and want different transition or presentation styles. This way, you set it each time as appropriate.

    AddNewItemViewController *newItemViewController = [[AddNewItemViewController alloc] initWithNibName:@"AddNewItemViewController" bundle:nil];
    newItemViewController.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentModalViewController:newItemViewController animated:YES];
    [newItemViewController release];

You're right in calling becomeFirstResponder in viewDidLoad.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文