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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:48:28+00:00 2026-05-23T10:48:28+00:00

I cannot set properties of a UILabel object. The following code is in a

  • 0

I cannot set properties of a UILabel object.

The following code is in a - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method:

UILabel *label = (UILabel *)[cell viewWithTag:0];
label.text = [self.comments objectAtIndex:indexPath.row*2];
label.textColor = [UIColor cyanColor];
label.adjustsFontSizeToFitWidth = YES;

All I get is a runtime error on the fourth line (curiously, the previous lines are ok):

2011-06-29 11:23:57.641 Esker Monitor[94138:207] -[UITableViewCell setAdjustsFontSizeToFitWidth:]: unrecognized selector sent to instance 0x4e889e0
2011-06-29 11:23:57.642 Esker Monitor[94138:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell setAdjustsFontSizeToFitWidth:]: unrecognized selector sent to instance 0x4e889e0'

Similiar label property modifications such as label.numberOfLines = 1; and label.minimumFontSize = 7.0; make the program crash too.

Is there something subtle I do not understand here?

  • 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-23T10:48:29+00:00Added an answer on May 23, 2026 at 10:48 am

    If you want to access label that’s built in standard UITableViewCell then use cell’s textLabel property:

    UILabel *label = cell.textLabel;
    ...
    

    If you add your custom label to a cell I’d suggest using some non-zero tag for it as 0 is a default tag value so

    [cell viewWithTag:0];
    

    can return any subview with 0 tag – not necessary you label. So assign some non-zero tag for your label and add it to cell’s contentView, not to the cell directly – that will help you to avoid some layout issues for example when cell goes to editing state. Later you can access that label the following way:

    UILabel *label = (UILabel*)[cell.contentView viewWithTag:kSomeNonZeroTag];
    

    The reason that text and textColor methods still work is that UITableViewCell actually implements that methods (they are originated from times when cell did not expose its labels publicly and are deprecated since SDK 3.0)

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

Sidebar

Related Questions

I have the following code that I have been using to Set properties in
I cannot get/set a static variable inside a method. How can I do it?
I cannot get IDataErrorInfo to validate reference properties that have [Required] attribute set to
How come constants cannot be set as properties of objects which are variables themselves?
i cannot set my theme's language to my language.. i've translated the needed field
I cannot set title_for_layout in the PagesController that comes by default with CakePHP 1.3.
I see there are several posts regarding Cannot set Property and I'm still struggling
I know that you cannot simply set DocumentRoot in htaccess but it's all I
I cannot get the DropDownHeight of the ComboBox set properly to display all the
I cannot figure out how to set an estimated maximum price for a collection

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.