我将如何为 iPhone/iPad 构建日历 UI 控件?
有一些不同的第 3 方代码框架包含日历控件,但其中大多数都有很多我不需要的功能,而且大多数都缺乏关于如何使用它们的足够文档,而且我不是一个足够熟练的 iPhone开发人员只需使用代码就可以解决这个问题。因此,我将尝试构建自己的项目,我希望您能为我提供一些高级的入门指导。在较高的层次上,我如何构建一个简单的日历控件,它除了显示日历(月视图,突出显示当前日期)并允许用户选择日期之外,没有什么作用?
看起来像此图像右上角的日历的东西...
替代文本 http://www.techtechies.com/wp-content/uploads/2010/01/calendar-on-ipad.jpg
非常感谢您的帮助!
There are a few different 3rd party code frameworks that include calendar controls, but most of them have a lot of functionality I don't need, plus most of them lack sufficient documentation on how to use them and I'm not a proficient enough iPhone developer to figure it out using just the code. So I'm going to attempt to build my own and I was hoping you could provide me with some high-level direction to get started. At a high level, how could I build a simple, calendar control that doesn't do much more than display a calendar (month view, with the current date highlighted) and allows the user to selected a date?
Something that looks like the calendar in the upper right corner of this image...
alt text http://www.techtechies.com/wp-content/uploads/2010/01/calendar-on-ipad.jpg
Thanks so much in advance for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚为客户构建了一个日历选择器类,这是一个严重的痛苦。你需要非常熟悉几个类:
Apple 确实对所有这些类都有很好的文档,但最终你最终会被砍掉,尤其是当你遇到夏令时等问题时。我必须处理的是 nsdate 既是时间又是日期的容器。因此,您必须规范或“抽象”处理日期比较的时间。需要注意的一件事是,如果构造 nsdates 时没有默认为午夜,那么夏令时日期实际上并不是午夜。
祝你好运!
I just got done building a calendar picker class for a client and it was a serious pain in the petoot. You're going to need to get extremely familiar with several classes:
Apple does have pretty good documentation on all these, but you'll end up hacking away eventually especially when you get to things like daylight savings time, etc. The biggest gotcha that I had to deal with is that nsdate is both a container for time and a date. So you have to normalize or "abstract" away the time to work with date comparisons. One thing to look out for is if construct nsdates without times they default to midnight which isn't really midnight on daylight savings dates.
Goodluck!
使用日历控件制作日历并不容易。我花了两个多月的时间来构建自定义日历。但它仍然没有给出最好的方法。
最好的方法是使用日历 api,然后您可以实现事件工具包。
如果你真的想花3个月时间制作日历,那就太浪费时间了。
使用api
Making a calendar with calendar controls is not really easy. It took me more than 2 months to build the custom calendar. But still it didn't give the best approach.
The best way is to use the calendar api and then you can implement event kit.
It would be waste of time if you really want to spend 3 months on making calendar.
Use the api