V
V
Vladislav Pavlenko2016-03-02 13:43:31
Objective-C
Vladislav Pavlenko, 2016-03-02 13:43:31

Why isn't footerView populated in UICollectionView?

Hello!
With headerView everything is fine, the data is displayed. But when I add footerView data... it's no good. What could be the problem?
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 = ;
        
        // 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;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
An, 2016-03-02
@pavlenkovs

some of the _weather property is a number and not a string as you would expect
in these lines [_weather valueForKeyPath:@"Temp"]
[_weather valueForKeyPath:@"Humidity"]
[_weather valueForKeyPath:@"WindSpeed"
] what kind of _weather object is this, I can’t tell you more precisely

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question