Answer the question
In order to leave comments, you need to log in
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?
- (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
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 questionAsk a Question
731 491 924 answers to any question