Всем привет!
С headerView все хорошо, данные отображаются. Но стоит мне добавить данные по footerView... ничего хорошего. В чем может быть проблема?
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
UICollectionReusableView *reusableView = nil;
if (kind == UICollectionElementKindSectionHeader)
{
HeaderReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header" forIndexPath:indexPath];
// date and time
NSDate *currentDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
// kCFDateFormatterLongStyle
[dateFormatter setDateStyle:3];
headerView.dateLabel.text = [dateFormatter stringFromDate:currentDate];
// kCFDateFormatterShortStyle
[timeFormatter setTimeStyle:1];
headerView.timeLabel.text = [timeFormatter stringFromDate:currentDate];
// temperature
headerView.temperatureLabel.text = [NSString stringWithFormat:@"%@%@", [_weather valueForKeyPath:@"Temp"], symbolDeg];
// humidity
headerView.humidityLabel.text = [NSString stringWithFormat:@"%@%%", [_weather valueForKeyPath:@"Humidity"]];
// wind
headerView.windLabel.text = [NSString stringWithFormat:@"%@ м/с", [_weather valueForKeyPath:@"WindSpeed"]];
// icon weather
NSString *url = [NSString stringWithFormat:@"http://openweathermap.org/img/w/%@.png", [_weather valueForKeyPath:@"Icon"]];
[headerView.iconWeather sd_setImageWithURL:[NSURL URLWithString:url]];
reusableView = headerView;
}
if (kind == UICollectionElementKindSectionFooter)
{
FooterReusableView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"footer" forIndexPath:indexPath];
footerView.electricity.text = [_powerAnalitic valueForKeyPath:@"<WattsNow>k__BackingField"];
footerView.costElectricityPerDay.text = [NSString stringWithFormat:@"%@%@",
[_powerAnalitic valueForKeyPath:@"<Cost>k__BackingField"],
[_powerAnalitic valueForKeyPath:@"<Currency>k__BackingField"]];
reusableView = footerView;
}
return reusableView;
}