如何在 iOS 7 日历 UIDatePicker 中显示日期选择器 [英] How to display datepicker like that in iOS 7 calendar UIDatePicker

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

问题描述

我是 iOS 开发的新手,正在学习一些零碎的东西.我还有几个查询继续到另一个线程(iOS7:Apple 如何使导航控制器看起来像日历应用程序中的 uiactionsheet) 在 iOS 7 上在默认日历中创建新事件,当我们单击 UINavigationBar 上的 + 时会显示该事件(我假设).

I'm new to iOS development, learning bits and pieces. I've few more queries in continuation to another thread (iOS7: How does Apple make a navigation controller look like a uiactionsheet in the calendar app) on iOS 7 new event creation in default calendar that's shown when we click + on UINavigationBar (I assume).

有谁知道如何创建 UIDatePicker 以便在我单击开始/结束日期字段时显示/隐藏它?我看到一个视频,其中 UIActionSheet 在 XCode 4.5 中使用,但在那个用户需要点击完成等按钮来隐藏它.在 iOS 7 日历中,当我单击外部选择器(即开始日期字段)时,它会隐藏.我希望问题很清楚?

Does anyone know how to create UIDatePicker so that its displayed/hidden when I click on Start/End date field? I saw one video where UIActionSheet was used in XCode 4.5, but in that user needs to click on Done etc button to hide it. In iOS 7 calendar its hidden when I click outside picker i.e. on Start Date field. I hope question is clear?

请告知如何实现此功能?

Kindly advise how to achieve this feature?

推荐答案

您可以尝试使用 OCCalendarController,它是如此简单和舒适.只需下载压缩文件并获取以前缀 OC 命名的所有文件.

You can try and use the OCCalendarController, Its so simple and comfortable. Just download the zipped file and get all the files named after the prefix OC.

OCCalendarViewController.m 中,您可以通过自己以编程方式添加确定"或取消"按钮来进行必要的更改.

Of which in OCCalendarViewController.m you can make the necessary changes by adding Okay or Cancel buttons programmatically, yourself.

要在主文件中调用日历视图,请使用以下行,

To call the calendar view in your main file use the lines,

//这就是魔法发生的地方calVC = [[OCCalendarViewController alloc] initAtPoint:CGPointMake(150, 50) inView:self.view];calVC.delegate = 自我;[self.view addSubview:calVC.view];

还要包括以下委托来接收日期选择(如果用户选择日期或日期范围)

Also do include the following delegate to receive the date selection(if the user selects a date or date range)

- (void)completedWithStartDate:(NSDate *)startDate endDate:(NSDate *)endDate {

最后你还可以使用代码自定义箭头(与日历视图一起出现),

Finally you can also customize the arrow(which appears along with the calendar view) by using the code,

[OCCalendarViewController alloc] initAtPoint:insertPoint inView:self.view arrowPosition:OCArrowPositionRight]

其余详细信息可在自述文件中找到.自己试试吧,它会像魅力一样工作.干杯!

Rest of the details can be found on the read me file. Try out yourself, It'll work like a charm.Cheers!

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

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