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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:28:39+00:00 2026-06-10T01:28:39+00:00

In the following code, if we do [cell addSubview: someLabel] vs [cell.contentView addSubview: someLabel]

  • 0

In the following code, if we do [cell addSubview: someLabel] vs [cell.contentView addSubview: someLabel], they seem to work the same. Is there any difference doing one or the other? (the custom cell in the real code is adding UIImageView and UILabel) (UIView, on the other hand, doesn’t have contentView, so we don’t need to add subview to its contentView. UITableViewCell is a subclass of UIView by the way)

-(UITableViewCell *) tableView:(UITableView *) tableView 
                       cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    UITableViewCell *cell = nil;

    if ([tableView isEqual:self.songsTableView]){

        static NSString *TableViewCellIdentifier = @"MyCells";

        cell = [tableView dequeueReusableCellWithIdentifier:TableViewCellIdentifier];

        if (cell == nil){
            cell = [[UITableViewCell alloc] 
                    initWithStyle:UITableViewCellStyleDefault
                    reuseIdentifier:TableViewCellIdentifier];
        }

        // ...  some code to create a UILabel (not shown here)

        [cell addSubview: someLabel];  // vs using [cell.contentView addSubView: ...]
  • 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-06-10T01:28:40+00:00Added an answer on June 10, 2026 at 1:28 am

    I believe If I am not wrong, the contentView is a subview of UITableViewCell.

    If you look at this page here, you can see there are actually 3 subviews in a UITableViewCell

    I think by default, the Editing Control is hidden until you enter edit mode for a table in which case, the Editing Control appears (the minus button left of each row) and your contentView gets resized and pushed to the right. This is probably what gives the “proper animation” effect mentioned by the other answer.

    To test the difference, try adding a subview such as UILabel with text, to the cell rather than the cell.contentView. When you add it to cell rather than cell.contentView and you enter edit mode for your table, I believe your UILabel will not resize, you will see the edit button ontop/below the minus sign button.

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

Sidebar

Related Questions

Currently I have the following code to flash a DataGrid cell when it's value
I'm using the following code to update a DataGridView's cell value. This is called
I have the following code that produces a background image in a table cell.
I'm using the following code to just make a single UILabel on my cell.
Following code gets executed whenever I want to persist any entity. Things seems to
I am using the following code to retrieve the content of a cell in
i use the following code to load image to a cell $(cell).css(background-image, url(+iconImage+)); As
I've got the following code in one of my view controllers: - (void)tableView:(UITableView *)tableView
I've got the following code which should put an image in the top section/cell
i have following code to create cell and add image to it UIImageView* MyImage

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.