单击特定网格视图单元格时淡出网格视图
在我的应用程序中,我的根视图是带有单元格的网格视图。当我点击特定单元格时,模式视图控制器将弹出该特定单元格的详细信息。
当我的模态视图存在时,如何淡出网格视图?
另外,当我点击模态视图后面的网格视图中的任意位置时,如何关闭模态视图?
In my app, my root view is a grid view with cells. When I tap a particular cell, the modal view controller will pop up with details of that particular cell.
How can I fade out the grid view when my modal view is present?
Also, how can I dismiss the modal view when I tap anywhere in the grid view, which is behind my modal view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iOS 5 引入了新的 UIViewController 方法,
presentViewController:animated:completion:
(为您链接的文档)当然您可能已经了解presentModalViewController:animated:
(文档说使用presentViewController
方法代替旧的presentModalViewController
,但这取决于您是否仅支持 iOS 5 和更高版本)。您可以将动画设置为 YES 并使用淡入淡出动画,或者将父视图的 alpha 设置为更接近 0.0(以稍微“淡出”它)。
UIView
文档有一些关于淡入淡出的注释,包括一些示例代码。看看animateWithDuration:animations:completion:
至于忽略模态视图,不会
dismissModalViewControllerAnimated:
有效吗?iOS 5 brought in a new UIViewController method,
presentViewController:animated:completion:
(documentation linked for you) and of course you probably already know aboutpresentModalViewController:animated:
(documentation says to use thepresentViewController
method in place of the olderpresentModalViewController
, but this depends on if you are supporting iOS 5 & newer only).You can set animated to YES and use a fade animation, or set the parent view's alpha closer to 0.0 (to "fade" it somewhat).
The
UIView
documentation has some notes about fading things, including some sample code. Look atanimateWithDuration:animations:completion:
As for dismissing the modal view, wouldn't
dismissModalViewControllerAnimated:
work?