Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6820867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:28:36+00:00 2026-05-26T21:28:36+00:00

I’ve a UITableView which when a cell has the same content that other, this

  • 0

I’ve a UITableView which when a cell has the same content that other, this content only appear in the las cell drawed. My custom cell adds an UIView property to add dynamic subviews from other class.

- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath
{   
    static NSString *MyIdentifier = @"cell";

    CollectionCell *cell = (CollectionCell *)[tableView 
                         dequeueReusableCellWithIdentifier:MyIdentifier];
    if (!cell) {
        cell = [[[CollectionCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                                  reuseIdentifier:MyIdentifier] 
                autorelease];
    }

    [cell setCollectionView:/* Generated view in other class */];  

    return cell;
}

The concrete problem is:

My dynamic view is composed by, for example, 2 UILabels:

  • if label 1 is a title, the title is unique for each row -> No problem, renders fine.
  • if label 2 is a category, indexes from 0 to 5 have same category -> Only row at index 5 shows category label.

I can’t create this labels in cell instantiation and add as subview because the cell content is all dynamic.

Thanks for your time and help.

UPDATE:

I can’t create this labels in cell instantiation and add as subview because the cell content is all dynamic.

I’m going to explain it in detail:

The content and UI controls added to collectionView property can be differentes each execution. In one execution collectionView could have an UIImageView and a UILabel, and next execution it has 2 UILabels (for example). This is why I can’t create something like this

    if (!cell) {
        cell = [[[CollectionCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                                  reuseIdentifier:MyIdentifier] 
                autorelease];

        UILabel *foo = [[UILabel alloc] initWithFrame:SomeFrame];
        [foo setTag:101];
        [cell.collectionView addSubview:foo];
    }

    UILabel *foo = [cell.collectionView subviewWithTag:101];
    [foo setTitle:@"This content is dynamic"];

Thanks!

Update 2:

Appears to be a problem with custom UILabel subclass. If I use original UILabel to show strings works fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:28:36+00:00Added an answer on May 26, 2026 at 9:28 pm

    You are not supposed to add subviews outside the block-

    if (!cell) {
            cell = [[[CollectionCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                                      reuseIdentifier:MyIdentifier] 
                    autorelease];
    }
    

    your subviews should only be added inside this block (the first time the reusable cell is created).

    everything that happens outside (after) this ‘if’ block happens multiple times as you scroll your table up and down so that’s where you edit the added subviews (only after the whole ‘if block, outside it).

    See my answer here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.