Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

DenTelezhkin/DTInlineDatePicker

Repository files navigation

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'

About

Display UIDatePicker inline easily!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •