Почему не заполняется footerView в UICollectionView?

Всем привет!
С headerView все хорошо, данные отображаются. Но стоит мне добавить данные по footerView... ничего хорошего. В чем может быть проблема?
e595c67c63b4437ebfbfe8bf9f03a39a.png
- (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;
}
  • Вопрос задан
  • 156 просмотров
Решения вопроса 1
Flanker_4
@Flanker_4
какое-то из свойство _weather является числом, а не строкой как Вы ожидаете
в этих строках [_weather valueForKeyPath:@"Temp"]
[_weather valueForKeyPath:@"Humidity"]
[_weather valueForKeyPath:@"WindSpeed"]

Но так как не ясно что это вообще за объект _weather, точней не подскажу
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы