This is an iOS control for selecting a date using UIDatePicker in an UIAlertController like manner

Overview

RMDateSelectionViewController Build Status Pod Version Carthage compatible

This framework allows you to select a date by presenting an action sheet. In addition, it allows you to add actions arround the presented date picker which behave like a button and can be tapped by the user. The result looks very much like an UIActionSheet or UIAlertController with a UIDatePicker and some UIActions attached.

Besides being a fully-usable project, RMDateSelectionViewController also is an example for an use case of RMActionController. You can use it to learn how to present a date picker other than UIDatePicker.

Screenshots

Portrait

White Black Sheet White  Sheet Black
Portrait Black Sheet Sheet-Black

Demo Project

If you want to run the demo project do not forget to initialize submodules.

Installation (CocoaPods)

platform :ios, '8.0'
pod "RMDateSelectionViewController", "~> 2.3.1"

Usage

For a detailed description on how to use RMDateSelectionViewController take a look at the Wiki Pages. The following four steps are a very short intro:

  • Import RMDateSelectionViewController:
#import <RMDateSelectionViewController/RMDateSelectionViewController.h>
  • Create select and cancel actions:
RMAction<UIDatePicker *> *selectAction = [RMAction<UIDatePicker *> actionWithTitle:@"Select" style:RMActionStyleDone andHandler:^(RMActionController<UIDatePicker *> *controller) {
    NSLog(@"Successfully selected date: %@", controller.contentView.date);
}];

RMAction<UIDatePicker *> *cancelAction = [RMAction<UIDatePicker *> actionWithTitle:@"Cancel" style:RMActionStyleCancel andHandler:^(RMActionController<UIDatePicker *> *controller) {
    NSLog(@"Date selection was canceled");
}];
  • Create and instance of RMDateSelectionViewController and present it:
RMDateSelectionViewController *dateSelectionController = [RMDateSelectionViewController actionControllerWithStyle:RMActionControllerStyleWhite title:@"Test" message:@"This is a test message.\nPlease choose a date and press 'Select' or 'Cancel'." selectAction:selectAction andCancelAction:cancelAction];

[self presentViewController:dateSelectionController animated:YES completion:nil];
  • The following code block shows you a complete method:
- (IBAction)openDateSelectionController:(id)sender {
    RMAction<UIDatePicker *> *selectAction = [RMAction<UIDatePicker *> actionWithTitle:@"Select" style:RMActionStyleDone andHandler:^(RMActionController<UIDatePicker *> *controller) {
        NSLog(@"Successfully selected date: %@", controller.contentView.date);
    }];
    
    RMAction<UIDatePicker *> *cancelAction = [RMAction<UIDatePicker *> actionWithTitle:@"Cancel" style:RMActionStyleCancel andHandler:^(RMActionController<UIDatePicker *> *controller) {
        NSLog(@"Date selection was canceled");
    }];
    
    RMDateSelectionViewController *dateSelectionController = [RMDateSelectionViewController actionControllerWithStyle:RMActionControllerStyleWhite title:@"Test" message:@"This is a test message.\nPlease choose a date and press 'Select' or 'Cancel'." selectAction:selectAction andCancelAction:cancelAction];
    
    [self presentViewController:dateSelectionController animated:YES completion:nil];
}

Migration

See Migration on how to migrate to the latest version of RMDateSelectionViewController.

Documentation

There is an additional documentation available provided by the CocoaPods team. Take a look at cocoadocs.org.

Requirements

Compile Time Runtime
Xcode 7 iOS 8
iOS 9 SDK
ARC

Note: ARC can be turned on and off on a per file basis.

Version 1.5.0 and above of RMDateSelectionViewController use custom transitions for presenting the date selection controller. Custom transitions are a new feature introduced by Apple in iOS 7. Unfortunately, custom transitions are totally broken in landscape mode on iOS 7. This issue has been fixed with iOS 8. So if your application supports landscape mode (even on iPad), version 1.5.0 and above of this control require iOS 8. Otherwise, iOS 7 should be fine. In particular, iOS 7 is fine for version 1.4.3 and below.

Apps using this control

Using this control in your app or know anyone who does?

Feel free to add the app to this list: Apps using RMDateSelectionViewController

Further Info

If you want to show an UIPickerView instead of an UIDatePicker, you may take a look at my other control called RMPickerViewController.

If you want to show any other control you may want to take a look at RMActionController.

Credits

Code contributions:

  • AnthonyMDev
    • Cancel delegate method should be optional
  • Digeon Benjamin
    • Delegate method when now button is pressed
    • Cancel delegate method is called when background view is tapped
  • Denis Andrasec
    • Bugfixes
  • Robin Franssen
    • Block support
  • Scott Chou
    • Images for cancel and select button
  • steveoleary
    • Bugfixes

Localizations:

  • Vincent Xue (Chinese)
  • Alex Studnička (Czech)
  • Robin Franssen (Dutch)
  • tobiasgr (Danish)
  • Thomas Besnehard (French)
  • Heberti Almeida (Portuguese)
  • Anton Rusanov (Russian)
  • Pedro Ventura (Spanish)
  • Aron Manucheri (Swedish)
  • Vinh Nguyen (Vietnamese)

I want to thank everyone who has contributed code and/or time to this project!

License (MIT License)

Copyright (c) 2013-2016 Roland Moers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Comments
  • RMAction problem on swift3

    RMAction problem on swift3

    I've updated the project to swift3 and was wondering when the support for this update is coming out?

    I've converted the syntax with default xCode helper, but now when I add action to RMDateSelectionViewController xCode through error: 'RMAction' requires that 'RMActionController' inherit from 'RMActionController'

    here is an example of ho wI use it:

    if let cancelAction = RMAction(title: NSLocalizedString("Cancel", comment: "Button title on date picker selector"), style: .cancel, andHandler: nil) { dateSelectionController.addAction(cancelAction as! RMAction<RMActionController>) }

    opened by ibakurov 17
  • Swift: NSAssert

    Swift: NSAssert

    Hi. im trying to use this library in swift, however i get this error: NSAssert(self.contentView != nil, @"Error: The view of an RMActionController has been loaded before a contentView has been set. You have to set the contentView before presenting a RMActionController.");

    Any ideas?

        let selectAction = RMAction(title: AppearanceService.textById(Texts.Ok), style: RMActionStyle.Done, andHandler: { (actionController) -> Void in
    
        })
        let cancelAction = RMAction(title: AppearanceService.textById(Texts.Cancel), style: RMActionStyle.Done, andHandler: { (actionController) -> Void in
    
        })
        let dateSelectionController = RMActionController(style: RMActionControllerStyle.White, selectAction: selectAction, andCancelAction: cancelAction)
        presentViewController(dateSelectionController, animated: true, completion: nil)
    
    opened by ivangodfather 13
  • More / Different Buttons

    More / Different Buttons

    I would like to a button which has "Don't select an End Date", I have this as a full width button in an action sheet at the moment, but I need to upgrade, is there anyway I can add a full width button.

    I thought I could re-use the now button and move it underneath the picker, but I can't :(

    Any thoughts ?

    enhancement 
    opened by JulesMoorhouse 11
  • iPad (popover) support example would be helpful

    iPad (popover) support example would be helpful

    On an iPad this control should be in a popover style. An example of this using your showFromViewController: method would be helpful for universal apps.

    opened by sedwo 11
  • import fail on Swift project

    import fail on Swift project

    screen shot 2015-06-10 at 10 12 55 pm

    The error cause by this line screen shot 2015-06-10 at 10 17 06 pm

    Change to #import <RMActionController/RMActionController.h> solve the issue

    P.S.Same issue at RMPickerViewController

    opened by retsohuang 10
  • Install instructions fail

    Install instructions fail

    platform :ios, '8.0' pod "RMDateSelectionViewController", "~> 2.0.0"

    Result:

    [!] Unable to satisfy the following requirements:

    • RMDateSelectionViewController (~> 2.0.0) required by Podfile
    opened by djclarkson 10
  • Could not load NIB in bundle

    Could not load NIB in bundle

    Hi,

    I'm experiencing a crash with the following exception:

    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </../appname.app> (loaded)' with name 'RMDateSelectionViewController''
    

    I'm using a pod file with the line: pod "RMDateSelectionViewController", "~> 1.0.0"

    Not sure what's going on yet, but I can see RMDateSelectionViewController.xib exists.

    bug 
    opened by talshr 10
  • Can't scroll minutes on iPhone5 in landscape mode

    Can't scroll minutes on iPhone5 in landscape mode

    To reproduce: start demo project rotate in landscape mode press "Show date..."

    If I rotate after showing the control - all works as expected.

    bug 
    opened by avgx 9
  • Date picker wheel not showing in iOS 8 iPhone

    Date picker wheel not showing in iOS 8 iPhone

    Hi,

    When I run the example application in the simulator with blur version , it shows the date picker wheel , but when I run the same example application in my iPhone ( iOS 8 ) it doesn't work .. It shows the black pop up with title & buttons , but not the date picker wheel. Without blur version it works well .. Any idea how to fix this ..

    Thanks a lot

    opened by udayasri 7
  • Showing Date Selector from iPhone landscape mode - window shaped incorrectly

    Showing Date Selector from iPhone landscape mode - window shaped incorrectly

    When I put my phone in landscape orientation and then show the date selector, it shows up in the middle of the view and it's cut-off, only showing a portion of the selector.

    It works fine if I show the selector in portrait and then turn the device to landscape, but not if I show the selector from in landscape mode.

    opened by AnthonyMDev 7
  • Landscape issue

    Landscape issue

    For iOS 7 support, I'm using 1.4.3 as advised in docs. Its working well when i switch to landscape from portrait but unable to adjust frame when i open it in landscape.

    opened by SMFakhir 6
  • I want only month and year column in date picker

    I want only month and year column in date picker

    Hi, I've been using this control for long, and It's amazing. I use this in my every project almost. I feel like there should be an option to show only month and year column in date picker, like for expiry date selection.

    Is there any way to implement like this, is it already exist? If so kindly do let me know what mode is that, because I don't find a way to make like this.

    Thanks Hassan

    opened by hassan31 0
  • Date Selector Doesn't handle iOS 13 dark mode

    Date Selector Doesn't handle iOS 13 dark mode

    Hello friend!

    We've noticed that on iOS 13 with Dark Mode enabled, the selector is invisible: IMG_3737B3100AAE-1

    I've gotten this to work for me by adding a:

    if #available(iOS 13.0, *) {
        actionController.overrideUserInterfaceStyle = .light
    }
    

    Right before presenting calendar selector!

    I also notice that I can't seem to set the style to anything dark, I was going to add a

    if #available(iOS 13.0, *) {
      puts("!: we are 13")
      if self.webViewController?.traitCollection.userInterfaceStyle == .dark {
           puts("!: We are dark")
          style = RMActionControllerStyle.black
       }
    }
    // then initialize the actionController
    let actionController: RMDateSelectionViewController = RMDateSelectionViewController(style: style)!
    

    However, even hardcoding it to .black seems to make keep it white!

    opened by chris-hut 3
  • In datetimepickermode, view goes outside the alert with style set as RMActionControllerStyleWhite

    In datetimepickermode, view goes outside the alert with style set as RMActionControllerStyleWhite

    Hi @CooperRS ,

    Thanks for the awesome library.

    The "M" and "W" of monday and wednesday goes out of the alertbox view when style is set as RMActionControllerStyleWhite. Please help me out with this.

    opened by hardikamal 2
  • Tap

    Tap "Select" before spinning ends, return pre-edited value

    This might be Apple UIDatePicker issue as well.

    While the picker is animating, if user tap on "Select", UI seems wait for a while to let datePicker settle down to the final value, but the return value will still show the original value.

    Tried capturing value through UIControlEventValueChanged, seems it able to return the final value even if DateSelectionViewController is dismissed.

    I'm not sure how it could be patched in the component itself since UIDatePicker doesn't expose much info about the UI. Maybe you have some better idea.

    bug Waiting for Apple 
    opened by japanconman 2
Releases(2.3.1)
Owner
Roland Moers
Roland Moers
This is an iOS control for presenting any UIView in an UIAlertController like manner

RMActionController This framework allows you to present just any view as an action sheet. In addition, it allows you to add actions around the present

Roland Moers 542 Dec 5, 2022
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...

Alerts & Pickers Advanced usage of native UIAlertController with TextField, TextView, DatePicker, PickerView, TableView, CollectionView and MapView. F

RV 5.5k Dec 22, 2022
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...

Alerts & Pickers Advanced usage of native UIAlertController with TextField, TextView, DatePicker, PickerView, TableView, CollectionView and MapView. F

RV 5.5k Dec 26, 2022
Use UIAlertController like a boss.

Description Requirements Installation CocoaPods Carthage Usage License Description CatAlertController is a high level manager object that with chainin

Kcat 8 Feb 8, 2022
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022
A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.

A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.

Ali Samaiee 11 Jun 6, 2022
A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

donggyu 5 Jan 26, 2022
Swifty, modern UIAlertController wrapper.

Alertift Alertift.alert(title: "Alertift", message: "Alertift is swifty, modern, and awesome UIAlertController wrapper.") .action(.default("❤️"))

Suguru Kishimoto 287 Jan 7, 2023
An easier constructor for UIAlertController. Present an alert from anywhere.

ALRT An easier constructor for UIAlertController. Present an alert from anywhere like this. ALRT.create(.alert, title: "Alert?").addOK().addCancel().s

Masahiro Watanabe 97 Nov 11, 2022
Easy Swift UIAlertController

EZAlertController Easy Swift UIAlertController One line setup for all UIAlertControllers Button action with closures instead of selectors Easily custo

Kan Yilmaz 366 Sep 14, 2022
Simple UIAlertController builder class in Swift.

Kamagari Simple UIAlertController builder class in Swift. Features AlertBuilder class to simply build UIAlertController by using method chaining UIAle

Kazunobu Tasaka 78 Nov 29, 2022
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

Paolo Musolino 2.5k Jan 3, 2023
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

Paolo Musolino 2.5k Jan 3, 2023
Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)

DOAlertController Simple Alert View written in Swift, which can be used as a UIAlertController replacement. It supports from iOS7! It is simple and ea

Daiki Okumura 406 Sep 5, 2022
An easy to use UIAlertController builder for swift

LKAlertController An easy to use UIAlertController builder for swift Features Short and simple syntax for creating both Alerts and ActionSheets from U

Lightning Kite 97 Feb 8, 2022
Customizable replacement for UIAlertController

ActionSheet Customizable replacement for UIAlertController. Requirements Installation Swift Package Manager The Swift Package Manager is a tool for au

Horizontal Systems 0 Oct 6, 2022
UIAlertController with continuity.

CuckooAlert Allow multiple use of presentViewController to UIAlertController. You may be disappointed from this. Do you imagine that cuckoo spit out s

Jay Choi 5 Feb 2, 2020
UIPicker inside a UIAlertController

DPPickerManager UIPicker inside a UIAlertController HOW TO USE : // Strings Picker let values = ["Value 1", "Value 2", "Value 3", "Value 4"] DPPickerM

Prioregroup.com 45 May 30, 2022
An easier constructor for UIAlertController. Present an alert from anywhere.

ALRT An easier constructor for UIAlertController. Present an alert from anywhere like this. ALRT.create(.alert, title: "Alert?").addOK().addCancel().s

Masahiro Watanabe 97 Nov 11, 2022