Code Monkey home page Code Monkey logo

dtinlinedatepicker's Introduction

CocoaPod platform   CocoaPod version   License MIT

DTInlineDatePicker

This is a project-extension for DTTableViewManager and DTPickerPresenter.

Starting with iOS 7, Apple encourages developers to present UIDatePickers in UITableView inline. Without any wrappers, this might take quite a bit of code to do. In fact, Apple's own example is about 450 lines of code. DTInlineDatePicker provides much easier way to do that.

Presenting UIDatePicker now can be just three lines of code:

NSIndexPath * indexPath = [NSIndexPath indexPathForRow:1 inSection:0];
DTDatePickerPresenter * presenter = [DTDatePickerPresenter presenterWithChangeBlock:^(NSDate * selectedDate)
{
   // Update your model with NSDate     
}];
    
[self attachInlinePickerPresenter:presenter toIndexPath:indexPath];

How to

In order to use DTInlineDatePicker classes, your table view controller needs to be subclassed from DTInlinePickerTableController. And you need to be using DTTableViewManager API to present your data models. Which you should try out, it is very nice =)

Responding to cell selection

Sometimes you'll want to react, when cell with date picker is selected. For example, add color to selected cell. DTInlineDatePicker provides two methods to do that:

- (void)didShowPickerForIndexPath:(NSIndexPath *)indexPath;
- (void)didHidePickerForIndexPath:(NSIndexPath *)indexPath;

Example project

To install dependencies for Example project, you need to be using CocoaPods. Clone the project and run

pod install

in project directory.

Requirements

  • iOS 7
  • ARC

Installation

Install using CocoaPods,

pod 'DTInlineDatePicker', '~> 0.1'

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.