In meiner App zeige ich einen Kalender an, und ich verwende eine Sammlungsansicht, um die Beschriftungen für die Wochentage anzuzeigen. Aus irgendeinem Grund zeigen alle Labels weiterhin die Standardbezeichnung "Label" an, wenn ich die App starte. Ich habe mir eine ähnliche Frage angesehen, aber es hat nicht geholfen. Irgendwelche Vorschläge? Hier ist der Code für die UICollectionViewCell:Beschriftung in UICollectionViewCell nicht aktualisiert
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CalendarTitleCellIdentifier forIndexPath:indexPath];
UILabel *label = (UILabel *)[cell viewWithTag:1];
label = [[UILabel alloc] init];
CGSize size = [self collectionView:collectionView layout:collectionView.collectionViewLayout sizeForItemAtIndexPath:indexPath];
label.frame = CGRectMake(0, 0, size.width, size.height);
NSString *title = [[NSString alloc] initWithFormat:@"%@",self.weektitles[indexPath.row]];
label.text = title;
NSLog(@"%@", label.text);
return cell;
}
FYI, ich habe ein tatsächliches Etikett im Storyboard (in der Sammlung Ansicht Zelle).
try UILabel * label = (UILabel *) [Zelle. contentView viewWithTag: 1]; – iOS