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 6379183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:06:18+00:00 2026-05-25T02:06:18+00:00

I want to display different UITableViewCell s depending on what content is available .

  • 0

I want to display different UITableViewCells depending on what content is available . How can I accomplish that ?

Example:

Lets say I have a custom UITableViewCell whose contentView has a UILabel, UITextField and a UIImageView as subviews. The UILabel is located on the top of the cell, above the UIImageView which is next to the UITextField. Depending on which contents for these views is available, I would like to only display the available parts and enlarge the other views. e.G: If there is missing the UILabel context I don’t want to have a blank space at the top of the cell. If I don’t have an image, the text field should start at the very left side of the cell.

There should be many newspaper/tv applications out there which had to solved exact the same problem…

Approaches:

(i) Using the same custom cell where I somehow rearrange the subviews

(ii) Calling different custom UITableViewCell‘s depending on what content is available

For both approaches I am having issues finding a path to solve this problem. My UITableView content size is dynamic and can have a few rows or many.

Is there any other approach I am missing out or if not which approach is best practice?

  • 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-25T02:06:19+00:00Added an answer on May 25, 2026 at 2:06 am

    Either approach works, although I would probably prefer (i).

    For (i), reuse is easy. Just make sure you clear out the old data when reusing, have your UITableViewCell’s layoutSubviews method lay the subviews out appropriately to match whatever data is available, and be sure to call setNeedsLayout when you change the data. The advantage here is that the rest of your code doesn’t need to care about which data is available or not, and your table may not even have to care if the cell suddenly gets an image added (unless it needs to know that the cell height changed or something). The disadvantage is that the cell’s implementation is more complex, and the layout cannot be completely defined in IB.

    For (ii), each different custom UITableViewCell type must have its own reuseIdentifier, and then use dequeueReusableCellWithIdentifier: with the identifier appropriate to the available data. The advantage here is that the individual cell types are simpler (and can probably be done entirely in IB), while the disadvantage is that you have to have several of them for each possible combination of available data. Also, you would need to have the UITableView reload the cell (e.g. using reloadRowsAtIndexPaths:withRowAnimation:) if the type needs to change.

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

Sidebar

Related Questions

I have some user-submitted variables that I want to display in a different part
I have forms that I want to display in different languages : I used
I have a simple form drop-down, and I want to display something different depending
I have a view which I want to display different things based on a
I want to create an Expanders that will display different configurations.. like color settings
I have to display different views for mobile devices and I want to provide
I have a table view with multiple sections. I want to display different section
I want to know how can I display different data in each cell of
I have created a tabs by jquery and i want to display different data
I want to display different context-sensitive content during a video playing on a website.

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.