DatePickerDialog-ObjC 1.2

DatePickerDialog-ObjC 1.2

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

gameleon-dev 维护。



  • Leon Lucardie

Swift 库的 Squimer 版本

此端口是为了使 DatePickerDialog 的功能可以在 Objective-C 项目中使用,而无需在您的应用程序二进制文件中导入 Swift 运行时(这可能会非常大增加应用程序二进制文件的大小)

DatePickerDialog - iOS - Objective-C

DatePickerDialog 是一个 iOS 抽象类,它可以在 UIAlertView 中显示 UIDatePicker。

要求

DatePickerDialog 在 iOS 8、9 和 10 上运行。它依赖于以下 Apple 框架,这些框架应该已经包含在大多数 Xcode 模板中:

  • Foundation
  • UIKit

安装

手动

  1. 下载并在您的项目中放入 LSLDatePickerDialog.hLSLDatePickerDialog.m
  2. 恭喜!

示例

#import "LSLDatePickerDialog.h"

@implementation ViewController {


-(void)openDatePicker {
      LSLDatePickerDialog *dpDialog = [[LSLDatePickerDialog alloc] init];
	    [dpDialog showWithTitle:@"DatePicker" doneButtonTitle:@"Done" cancelButtonTitle:@"Cancel"
		      defaultDate:[NSDate date] minimumDate:nil maximumDate:nil datePickerMode:UIDatePickerModeDate
		      callback:^(NSDate * _Nullable date){
		  	  if(date)
         		  {
			  	NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
            		 	[formatter setDateStyle:NSDateFormatterMediumStyle];
				NSLog(@"Date selected: %@",[formatter stringFromDate:date]);
	 		  }
		      }
	     ];
}

对话框初始化参数

  • showCancelButton: Bool - 默认 true
  • locale: Locale - 默认 nil

不带 '取消' 按钮的示例初始化

LSLDatePickerDialog *dpDialog = [[LSLDatePickerDialog alloc] initWithCancelButton:NO];

带 locale 的示例初始化

LSLDatePickerDialog *dpDialog = [[LSLDatePickerDialog alloc] initWithLocale:[Locale localeWithLocaleIdentifier:@“ja_JP”]];

显示参数

  • title: String (必需)
  • doneButtonTitle: String
  • cancelButtonTitle: String
  • defaultDate: Date
  • minimumDate: Date
  • maximumDate: Date
  • datePickerMode: UIDatePickerMode (必需)
  • callback: ((date: Date) -> Void) (必需)

特别感谢

许可证

本代码根据MIT许可协议分发。