点击我希望select/deselect
随机多个日期。用户应该能够选择多个日期(Ex: I should be able to select 2 Dec 2014, 8 Dec 2014 and 18 dec 2014. all these three dates should look selected.
)。目前我正在使用DLSCalendar。 DLSCalendar支持单日期选择和范围选择。
任何其他支持上述功能的lib都是受欢迎的
感谢。
答案 0 :(得分:0)
请更准确地说明您想要完成的任务。
如果您尝试在objective-c中创建随机日期,则可以执行以下操作:
// Objective-c Random date picker
//SET Day integers
int lowerday = 1;
int upperday = 31;
//SET Month integers
int lowermonth = 1;
int uppermonth = 12;
//SET Year integers
int loweryear = 1;
int upperyear = 2025; //Or any random year, but always higher then loweryear!
//Generate random Date
int monthvalue = lowermonth + arc4random() % (uppermonth - lowermonth); //Month
int yearvalue = loweryear + arc4random() % (upperyear - loweryear ); //Year
//Days differ each month so we should account for that
NSArray *highmonth =@[@"1",@"3",@"5",@"7",@"8",@"10",@"12"]; //Months with 31 days
NSArray *lowmonth =@[@"4",@"6",@"9",@"11"]; //Months with 30 days
NSString *secondmonth =@"2";
NSString *random_month =[NSString stringWithFormat:@"%d",monthvalue];
int dayvalue;
if ([highmonth containsObject:random_month]) {
//Do nothing the upperday is correctly set
}else if([lowmonth containsObject:random_month]){
upperday=30;
}else if([random_month isEqualToString:secondmonth]){
//To options 28 or 29 days
if (fmod(monthvalue, 1.0) == 0.0) {
//29 Days
upperday=29;
}else{
//28 Days
upperday=28;
}
}
dayvalue = lowerday + arc4random() % (upperday - lowerday ); //Day
//Create NSDate and give our random numbers
NSString *dateString = [NSString stringWithFormat:@"%d-%d-%d",dayvalue,monthvalue,yearvalue];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd-MM-yyyy"];
NSDate *dateFromString=[dateFormatter dateFromString:dateString];
//Check Random Date
if (dateFromString==nil) {
NSLog(@"Could not create random date");
}else{
NSLog(@"Succes! The Date was: %@",dateFromString);
}
答案 1 :(得分:0)
与{strong>选择/取消选择随机多个日期相关的DSLCalendarView更改。
例如:我应该可以选择2014年12月2日,2014年12月8日和2014年12月18日。所有这三个日期都应该选中。
谢谢:)