我想两个日期和I am getting the images successfully.的范围内获取从照片库影像使用PHAsset图书馆PHFetchResults日期过滤器不产生时间范围内正确的结果
现在的问题是,我不能够两者之间获得的图像像12:10 PM之间在同一天的时间到12:30 PM
使用下面的代码
NSDate *startDate = [self getDateForDay:30 andMonth:9 andYear:2016 andHour:12 andMinute:10 andSecond:0];
NSDate *endDate = [self getDateForDay:30 andMonth:9 andYear:2016 andHour:12 andMinute:30 andSecond:0];
-
-(NSDate*) getDateForDay:(NSInteger) day andMonth:(NSInteger) month andYear:(NSInteger) year andHour:(NSInteger) hour andMinute:(NSInteger) minute andSecond:(NSInteger) second{
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setDay:day];
[comps setMonth:month];
[comps setYear:year];
[comps setHour:hour];
[comps setMinute:minute];
[comps setSecond:second];
NSCalendar* gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
[gregorian setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
NSDate *date = [gregorian dateFromComponents:comps];
return date;
}
个
- 然后把这些日期如下方法来获得图像
PHFetchResult *result = [self getAssetsFromLibraryWithStartDate:startDate andEndDate:endDate];
日期和时间来正确的,当我在日志打印,但没有得到图像
如何解决这个问题呢?
您是否正确设置了时区?此处创建的日期将采用UTC时区,而您的日期可能会有所不同。确保你已经设置了日历的时区,例如'[calendar setTimeZone:[NSTimeZone systemTimeZone]];'在创建日期之前 – NSNoob
并且还要确保在时间范围内存在库中的图像 – NSNoob
检查我编辑的问题...雅我有图像肯定 –