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

查看:146
本文介绍了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天全站免登陆