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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:44:59+00:00 2026-05-28T05:44:59+00:00

I have a custom UITableViewCell created in IB. All my cells will have this

  • 0

I have a custom UITableViewCell created in IB.
enter image description here

All my cells will have this general layout. However,in some cells, the two white views will be classA and in other cells the two white views will be classB. (Both subclasses of UIView). I tried to assign the specific subclass of the two views using properties.

I set the two views as properties of the cell

@property (nonatomic, retain) IBOutlet UIView *leftView;
@property (nonatomic, retain) IBOutlet UIView *rightView; 

And in my view controller where I make the table view, I tried creating an object of type subclassA and assigning it as leftView, so that leftView will be of type subclassA. In other cells, I would create an object of subclass B and set it to leftview, so that in those cells, left view would be of subclass b.

//equationTextField is a subclass of UIView
EquationTextField *textField = [[EquationTextField alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; // arbitrary frame
cell.leftView = textField;

This code doesn’t work, however. Is there a better way to assign the specific class of my views?

  • 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-28T05:44:59+00:00Added an answer on May 28, 2026 at 5:44 am

    What you are doing is fine, but you may want to investigate having two different cell types (with your custom views already embedded) to improve performance – each could have a different reuse identifier which you would choose depending on the index path. Creating views every time in cellForRowAtIndexPath is never a good idea.

    You could even derive both types from the same cell, just use the different reuse identifier and add in the correct subclasses only when first creating the cell.

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

Sidebar

Related Questions

I cannot figure this one out. I have a created a custom UITableViewCell in
I have a custom UITableViewCell created through code (not Interface Builder). I have sub-views
I am facing this very weird problem, I have created a custom UITableViewCell on
I have a custom UITableViewCell which has an image & and some text. When
Similar to this question I have a custom subclass of UITableViewCell that has a
I have a custom UITableViewCell which I created in Interface Builder. I am successfully
I have created a custom UITableViewCell , but when I dequeue the cell, sometimes
I have a custom UITableViewCell which has some subviews. i.e. some labels, some images.
I have a custom-subclassed UITableViewCell which will include a few labels, to which I
I have a simple problem. I created a custom UITableViewCell that includes a UISwitch

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.