如何在不占用整个屏幕的UIView上使用UIModalTransitionStylePartialCurl? [英] How can I use UIModalTransitionStylePartialCurl on a UIView that does NOT take up the whole screen?

查看:144
本文介绍了如何在不占用整个屏幕的UIView上使用UIModalTransitionStylePartialCurl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Apple官方的iPhone地图应用中,右下角有一个小的页面卷曲按钮。按下它时,地图本身会向后剥离以显示一些选项。我想在我自己的应用程序中复制此效果。

In Apple's official Maps app for the iPhone, there is a small 'page curl' button in the lower-right corner. When you press it, the map itself peels back to reveal some options. I would like to duplicate this effect in my own app.

我正在尝试使用UIModalTransitionStylePartialCurl(在SDK 3.2中添加)。就其布局而言,我的应用程序几乎完全类似于Apple的官方地图应用程序。我可以轻松地将整个屏幕剥离,露出下面的另一个视图,但我不想要这个。我只想让地图视图剥离。

I'm trying to use UIModalTransitionStylePartialCurl (Added in SDK 3.2). In terms of its layout, my app resembles Apple's official Maps app almost exactly. I can easily get the ENTIRE screen to peel back, revealing another view underneath, but I don't want this. I want ONLY the map view to peel back.

为了创建这种效果,你必须有一个UIViewController来执行转换。如果我将这个UIViewController的视图设置为屏幕上某个不占用整个屏幕的小子视图,我可以将该子视图剥离。那很棒!但是,在转换的第二部分(当页面重新放回原位)之后,视图永远不会从它们开始的位置开始。剥离的视图将从其原始位置移开,或者显示的视图将扩展为占据整个屏幕。

In order to create this effect, you must have a UIViewController that will perform the transition. If I set this UIViewController's view to a small subview somewhere on the screen that does not take up the entire screen, I can get just that subview to peel back. That's great! However, after the second part of the transition (when the page falls back into place), the views are never where they started. Either the view that peeled back will have moved from its original position, or the view that was revealed will have expanded to take up the entire screen.

是否有任何明显的错误我正在制作?我真的很感激任何帮助!

Is there any obvious mistake that I'm making? I would really appreciate any help!

我使用的代码非常简单。它基本上只是:

The code I'm using is really simple. It's basically just:

underMapViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;

[curlableMapViewController presentModalViewController:underMapViewController animated:YES];


推荐答案

来自文档


UIModalTransitionStylePartialCurl

当显示视图控制器,当前视图的一个角向上卷起以显示下面的模态视图。在解雇时,蜷缩的页面会在模态视图之上展开。使用此转换呈现的模态视图本身无法呈现任何其他模态视图。

When the view controller is presented, one corner of the current view curls up to reveal the modal view underneath. On dismissal, the curled up page unfurls itself back on top of the modal view. A modal view presented using this transition is itself prevented from presenting any additional modal views.

仅当父视图控制器呈现完整视图时才支持此转换样式 - 屏幕视图,您使用UIModalPresentationFullScreen模式演示文稿样式。尝试为父视图或不同的演示文稿样式使用不同的形状因子会触发异常。

This transition style is supported only if the parent view controller is presenting a full-screen view and you use the UIModalPresentationFullScreen modal presentation style. Attempting to use a different form factor for the parent view or a different presentation style triggers an exception.

虽然,我还没有除全屏外使用其他演示文稿的任何异常。我正在测试,我遇到了和你一样的问题。我发现如果我的ParentViewController的视图是ImageView,并且我将内容模式设置为UIViewContentModeCenter,则视图不会调整大小或移动。也许有一种解决方法是将当前视图保存为图像,将其置于顶部,进行卷曲,然后在关闭模式后,重新排列混乱的隐藏内容并删除顶部图像视图。我知道这听起来很疯狂,但如果我真的必须完成这个要求,那就是我会尝试的。

Although, I haven't got any exception using other presentations than full screen. I was testing out and I get the same problem as you. I found that if my ParentViewController's view is an ImageView and I set the content mode to UIViewContentModeCenter, the view is not resized or moved. Maybe there is a workaround by saving your current view as an image, put it at the top, make the curl, and after you dismiss your modal, rearrange the messed hidden stuff and remove the top image view. I know that it sounds crazy but that is what I would try if I really had to accomplish that requirement.

希望这会有所帮助,Jorge。

Hope this helps, Jorge.

这篇关于如何在不占用整个屏幕的UIView上使用UIModalTransitionStylePartialCurl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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