RMDateSelectionViewController 2.3.1

RMDateSelectionViewController 2.3.1

测试测试过
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2017年9月

Roland Moers 维护。




  • 作者:
  • Roland Moers

此框架允许您通过显示一个操作表来选择日期。此外,它允许您在显示的日期选择器周围添加动作,这些动作的行为类似于按钮,并可以由用户触摸。结果显示看起来非常像带有 UIDatePicker 和一些 UIAction 的 UIActionSheet 或 UIAlertController。

除了是一个可用项目外,RMDateSelectionViewController 还是一个用来展示 RMActionController 使用案例的示例。您可以使用它来学习如何以不同于 UIDatePicker 的方式显示日期选择器。

屏幕截图

纵向

白色 黑色
Portrait Colors

横向

Landscape

示例项目

如果您想运行示例项目,不要忘记初始化子模块。

使用方法

关于如何使用 RMDateSelectionViewController 的详细描述,请参阅 Wiki 页面。以下四个步骤是一个非常简短的概述

  • 导入 RMDateSelectionViewController
#import <RMDateSelectionViewController/RMDateSelectionViewController.h>
  • 创建选择和取消操作
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 的实例并显示它
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];
  • 以下代码块显示了一个完整的方法
- (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];
}

迁移

有关如何迁移到 RMDateSelectionViewController 最新版本的信息,请参阅 迁移

文档

由 CocoaPods 团队提供的附加文档。请参阅 cocoadocs.org

要求

编译时间要求 运行时要求
Xcode 7 iOS 8
iOS 9 SDK
ARC

注意:可以在每个文件基础上关闭或开启 ARC。

RMDateSelectionViewController 版本 1.5.0 及以上版本使用自定义过渡效果来展示日期选择控制器。自定义过渡是苹果于 iOS 7 中引入的新特性。不幸的是,在 iOS 7 的横屏模式下,自定义过渡效果完全失效。此问题已在 iOS 8 中得到修复。因此,如果你的应用程序支持横屏模式(包括 iPad),则需要使用 1.5.0 及以上版本的此控件,并且需要 iOS 8 系统支持。否则,iOS 7 应该可以正常使用。特别是,iOS 7 对 1.4.3 及以下版本是兼容的。

使用此控件的应用程序

在你的应用中使用此控件或知道有人在用吗?

请自由地将应用程序添加到以下列表中:使用 RMDateSelectionViewController 的应用程序

更多信息

如果你想显示 UIPickerView 而不是 UIDatePicker,你可以看看我的另一个名为 RMPickerViewController 的控件。

如果你想显示其他控件,可以看看 RMActionController

致谢

代码贡献

  • AnthonyMDev
    • 取消代理方法应该是可选的
  • Digeon Benjamin
    • 当点击现在按钮时调用的代理方法
    • 当点击背景视图时调用取消代理方法
  • Denis Andrasec
    • 修复错误
  • Robin Franssen
    • 添加了块支持
  • Scott Chou
    • 取消和选择按钮的图像
  • steveoleary
    • 修复错误

本地化

  • Vincent Xue (中文)
  • Alex Studnička (捷克)
  • Robin Franssen (荷兰)
  • tobiasgr (丹麦)
  • Thomas Besnehard (法语)
  • Heberti Almeida (葡萄牙)
  • Anton Rusanov (俄语)
  • Pedro Ventura (西班牙)
  • Aron Manucheri (瑞典)
  • Vinh Nguyen (越南)

我要感谢所有为这个项目贡献代码和时间的人!

许可证(MIT 许可)

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.