iOS 7 - 如何在表格视图中显示日期选择器? [英] iOS 7 - How to display a date picker in place in a table view?

查看:33
本文介绍了iOS 7 - 如何在表格视图中显示日期选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 WWDC 2013 视频中,Apple 建议在 iOS 7 的表格视图中就地显示选择器.如何在表格视图单元格之间插入视图并为其设置动画?

In WWDC 2013 video, Apple suggests displaying picker in place in a table view in iOS 7. How to insert and animate a view between table view cells?

像这样,来自 Apple 日历应用程序:

Like this, from the Apple calendar app:

推荐答案

在 iOS7 中,Apple 发布了示例代码 DateCell.

With iOS7, Apple released the sample code DateCell.

演示表格单元格中日期对象的格式化显示以及使用 UIDatePicker 编辑这些值.作为此表的委托,示例使用didSelectRowAtIndexPath"方法打开 UIDatePicker 控件.

Demonstrates formatted display of date objects in table cells and use of UIDatePicker to edit those values. As a delegate to this table, the sample uses the method "didSelectRowAtIndexPath" to open the UIDatePicker control.

对于 iOS 6.x 及更早版本,UIViewAnimation 用于在屏幕上向上滑动 UIDatePicker,在屏幕外向下滑动.对于 iOS 7.x,UIDatePicker 内嵌添加到表格视图中.

For iOS 6.x and earlier, UIViewAnimation is used for sliding the UIDatePicker up on-screen and down off-screen. For iOS 7.x, the UIDatePicker is added in-line to the table view.

UIDatePicker的action方法会直接设置自定义表格单元格的NSDate属性.此外,本示例展示了如何使用 NSDateFormatter 类实现自定义单元格的日期格式外观.

The action method of the UIDatePicker will directly set the NSDate property of the custom table cell. In addition, this sample shows how to use NSDateFormatter class to achieve the custom cell's date-formatted appearance.

您可以在此处下载示例代码:DateCell.

You can download the sample code here: DateCell.

这篇关于iOS 7 - 如何在表格视图中显示日期选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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