GithubHelp home page GithubHelp logo

isabella232 / mdcalendar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from minima/mdcalendar

0.0 0.0 0.0 212 KB

Calendar date picker for iOS 7

License: MIT License

Ruby 0.98% Objective-C 99.02%

mdcalendar's Introduction

MDCalendar

MDCalendar is a calendar-style date picker for iOS 7 (and above) that uses UICollectionView to layout a calendar in the popular "month view" format.

example_calendar

Implementation Notes

MDCalendar was developed with flexibility in mind and is consequently implemented as a subclass of UIView. This means that a calendar may be instantiated as a subview in an existing view hierarchy or pushed onto a navigation stack as the sole view of a UIViewController. The latter behavior is demonstrated in the MDCalendarDemo project.

One of the philosophies used while designing MDCalendar was to minimize an explicit storage-based model. As a result, the vast majority of date and geometry math is calculated on-the-fly. Caching, particularly for the geometric calculations has been implemented, and MDCalendar has been tested with an endDate of [NSDate distantFuture].

Usage Example

Suppose a view controller called EventDetailsViewController wants to allow users to modify the date of the event using a nice calendar picker. Hmm... let's use MDCalendar for that! EventDetailsViewController is a subclass of UITableViewController and selecting one of the rows should push a calendar on-screen and allow users to modify the eventDate property of the EventDetailsViewController

The advised implementation of this is to create a sparse view controller to display an MDCalendar (see the demo project for an example of how to do that). This view controller, let's call it MDEventCalendarViewController (creative, I know), will be pushed onto the navigation stack.

Events & Delegation

In the above example, we will need to communicate calendar events back to its parent view controller. In order to do this elegantly, subclass MDCalendarDelegate in MDEventCalendarViewController and expose this protocol, MDEventCalendarDelegate, in the view controller's header. Now, the parent view controller, EventDetailsViewController, can set its delegate: id<MDEventCalendarDelegate>delegate

This delegate will essentially pass messages from MDCalendarDelegate onto the parent view controller. Advantages of subclassing MDCalendarDelegate is that if you were to re-use your sparse view controller it could contain some logic of how to interperet MDCalendarDelegate events.

Accessibility

Version 1.0.0 of MDCalendar features VoiceOver support with proper accessibility labels for each date.

mdcalendar's People

Contributors

distefam avatar simonrice avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.