Each time you press the reload button, you add a new label. You must add the label once and change the label text to match.
Here is a simple example.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { MyCell *cell = (MyCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; [cell setMyTextLabel:indexPath.row]; return cell; }
where MyCell will contain the UILabel and the property to change its text.
I really suggest taking a look at Fun with the UICollectionView code from @Ben Scheirman .
Hope this helps.
PS Rename MyCell to MyCell . The class must begin with an uppercase letter.
source share