在 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.
希望这会有所帮助,豪尔赫.
Hope this helps, Jorge.
这篇关于如何在不占用整个屏幕的 UIView 上使用 UIModalTransitionStylePartialCurl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!