BRPickerView
BRPickerView copied to clipboard
部分日期dateFromString格式化出来date=nil
当使用时间选择器是默认日期使用1949-05-01(不止这个日期)时,切换日期会因为时区的问题导致无法选中默认日期
-
(NSDate *)br_getDate:(NSString *)dateString format:(NSString *)format { NSDateFormatter dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.locale = [NSLocale currentLocale]; / //设置转换后的目标日期时区 NSTimeZone *toTimeZone = [NSTimeZone localTimeZone]; //转换后源日期与世界标准时间的偏移量 NSInteger toGMTOffset = [toTimeZone secondsFromGMTForDate:[NSDate date]];
dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:toGMTOffset]; */ dateFormatter.timeZone = [NSTimeZone localTimeZone]; dateFormatter.dateFormat = format; NSDate *destDate = [dateFormatter dateFromString:dateString];
return destDate; } BRErrorLog(@"参数格式错误!参数 defaultSelValue 的正确格式是:%@", self.selectDateFormatter); NSAssert(defaultSelDate, @"参数格式错误!请检查形参 defaultSelValue 的格式");
👍非常感谢!👍,已修复!😊
搭个车... 想邀请Repo作者来w3c.group创建项目的对应小组。w3c.group是类似知识星球的社群工具,小组可设置为付费且有赞助功能,同时也是一个区块链主导的创作者社区。这是相关介绍: http://t.cn/Ai1vLcCU http://t.cn/Ai1vLcCG http://t.cn/Ai1vLcCA