DTInlineDatePicker 0.3.0

DTInlineDatePicker 0.3.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Aug 2020

Maintained by Denys Telezhkin.



 
Depends on:
DTTableViewManager~> 3.0
DTPickerPresenter~> 0.1
 

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'