如何实现像日历中的日期选择器一样滑出的视图? [英] How does one implement a view that slides out like the date picker in calendar?

查看:18
本文介绍了如何实现像日历中的日期选择器一样滑出的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力实现一些在 iOS7 中添加日历事件时滑出的日期选择器.此处有一个示例.通过点击一个单元格并显示更多单元格或图像,这将非常适合减少混乱并在我的应用程序中保留上下文.我根本无法弄清楚.

I've been struggling to implement something a la the date picker that slides out when adding a calendar event in iOS7. There's an example pictured here. This would be perfect for reducing clutter and keeping context in my app by tapping a cell and revealing more cells or an image. I just cannot figure it out at all.

有人知道这样做的方法吗?

Does anyone know of a way to do this?

我想说得有点抽象,因为任何视图都能够在被选中时出现并将所有其他视图内容向下推.

I'd like to be a bit abstract, for any view to be able to appear when selected and push all the other view content down.

推荐答案

看起来他们在分组的 tableView 中拥有所有内容,并且当他们希望该日期选择器显示时他们正在调用 insertRow 方法,并让选择器设置是日期选择按钮下单元格的内容.他们正在调用以下方法来添加它:

It looks like they have everything in a grouped tableView and they are calling the insertRow method when they want that date picker to show up, and have the picker set the be the content of the cell under the date select button. They are calling the following method to add it:

-(void)insertRowsAtIndexPaths:(nonnull NSArray<NSIndexPath *> *)indexPaths withRowanimation:(UITableViewRowAnimation)animation

从它的外观来看很可能是一个淡入淡出的动画:

With most likely a fade animation from the looks of it:

 UITableViewRowAnimationFade

当他们想摆脱它时,他们也会以相同的方式调用 removeSections.

They also call the removeSections in the same way when they want to get rid of it.

如果尝试实现这一点,请确保调整 UITableViewDataSource 方法正在使用的数据,否则会因为更新后的行数无效而崩溃.

If trying to implement this, make sure you adjust the data your UITableViewDataSource methods are using or it will crash because of an invalid number of rows after the update.

这篇关于如何实现像日历中的日期选择器一样滑出的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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