Latest 0.3.0
Homepage https://github.com/DenHeadless/DTInlineDatePicker
License MIT
Platforms ios 7.0, requires ARC
Dependencies DTTableViewManager, DTPickerPresenter
Authors

CocoaPod platform  
CocoaPod version  
License MIT

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'

Latest podspec

{
    "name": "DTInlineDatePicker",
    "version": "0.3.0",
    "license": "MIT",
    "summary": "Display UIDatePicker inline easily!",
    "homepage": "https://github.com/DenHeadless/DTInlineDatePicker",
    "authors": {
        "Denys Telezhkin": "[email protected]"
    },
    "social_media_url": "https://twitter.com/DTCoder",
    "source": {
        "git": "https://github.com/DenHeadless/DTInlineDatePicker.git",
        "tag": "0.3.0"
    },
    "source_files": "DTInlineDatePicker",
    "requires_arc": true,
    "platforms": {
        "ios": "7.0"
    },
    "ios": {
        "frameworks": [
            "UIKit",
            "Foundation"
        ]
    },
    "dependencies": {
        "DTTableViewManager": [
            "~> 3.0"
        ],
        "DTPickerPresenter": [
            "~> 0.1"
        ]
    }
}

Pin It on Pinterest

Share This