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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:18:34+00:00 2026-05-26T06:18:34+00:00

why does setting a UITableViewCell ‘s color work in willDisplayCell but not in cellForRowAtIndexPath

  • 0

why does setting a UITableViewCell‘s color work in willDisplayCell but not in cellForRowAtIndexPath?

Notes:

  1. I’m using this code to set the background color of a cell: [cell setBackgroundColor:[UIColor yellowColor]];
  2. works when I put it in the method - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  3. does NOT work if I put in in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  • 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-26T06:18:34+00:00Added an answer on May 26, 2026 at 6:18 am

    The doco for UITableViewCell states that you need to do it in willDisplayCell: (excerpt from the UITableViewCell class reference below). I suspect that because table cells have a content view and various other components that seem to be ‘managed’ by UIKit, that its doing its own thing with the background color after its set in cellForRowAtIndexPath. You can also use the ‘backgroundView’ property of a table view cell to control its background.

    documentation excerpt:

    Note: If you want to change the background color of a cell (by setting the background color of a cell via the backgroundColor property declared by UIView) you must do it in the tableView:willDisplayCell:forRowAtIndexPath: method of the delegate and not in tableView:cellForRowAtIndexPath: of the data source. Changes to the background colors of cells in a group-style table view has an effect in iOS 3.0 that is different than previous versions of the operating system. It now affects the area inside the rounded rectangle instead of the area outside of it.

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

Sidebar

Related Questions

Why doesn't UITableViewCell background color work (set in interface builder)? I note from some
Does setting this value have the same effect as setting the debug=true in the
Simply setting the SVN_EDITOR variable to mate does not get the job done. It
Is there a good tutorial or does anyone have experience with setting this up
Appears that WAS does not support the integration binding. I've tried setting it up
When using TextRenderer.DrawText(), what does setting the TextFormatFlags.Internal flag actually do? Equivalently, what does
I've read a few posts on this, but there's still one thing that's not
Does setting of width and height only work in jquery if the element is
Here's how my cells are set up: - (UITableViewCell *)tableView:(UITableView *)tableViewIn cellForRowAtIndexPath:(NSIndexPath *)indexPath {
What does setting SubClassFetchMode e.g. to EAGER_PARALLEL actually do? Why would one want a

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.