如何显示日历像这样在iOS 7日历UIDatePicker [英] How to display datepicker like that in iOS 7 calendar UIDatePicker

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

问题描述

我是iOS新手,学习零件。
我还有几个查询继续到另一个线程()在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; [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]

详细信息可以在read me文件中找到。试试自己,它会像一个charm.Cheers工作。

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天全站免登陆