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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:03:33+00:00 2026-06-14T18:03:33+00:00

I have a UITableView which is made up of my own custom UITableViewCell s,

  • 0

I have a UITableView which is made up of my own custom UITableViewCells, subclassed as CustomCell. I add a UITextField to that cell and a method runs on certain events (from the text field).

When this method runs, I need to access the CustomCell that the text field is a subview of.

So I thought, how can I access the parent view of the text field (the CustomCell)?

I have tried this, get the text field, the sender of the method, then from that get its superview.

CustomTextField *textField = sender;
    CustomCell *cell = (CustomCell *)[textField superview];

However this fails, when I try to access a property of my cell, the app crashes and I get this in the console: [UIView myLabel]: unrecognized selector sent to instance. (myLabel is the property I am trying to access on the cell.)

Why doesn’t this work, or is there an alternative method of accessing that cell?

  • 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-14T18:03:34+00:00Added an answer on June 14, 2026 at 6:03 pm

    You are not supposed to add your views as direct subviews of a UITableViewCell. Instead, you are supposed to add them as subviews of the cell’s contentView. If you lay out your cell in a xib, Interface Builder will automatically take care of this for you. So in general you should not expect the cell to be the direct superview of your text field.

    I would handle this in one of two ways:

    1. Give CustomTextField a weak property that references its containing CustomCell. Then you can just ask the text field for its cell. If you’re using a xib, make the property an IBOutlet and hook it up in the xib. If you’re creating the cell in code, set the property in code when you create the cell and the text field.

    2. Walk up the view hierarchy looking for the CustomCell ancestor.

      CustomCell *cell = textField.superview;
      while (cell && ![cell isKindOfClass:[CustomCell class]]) {
          cell = [cell superview];
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have UITableView which uses a custom UITableViewCell containing a UITextField . I want
I've made a UITableView with cells which have different height. On each cell, I've
I have an UITableView which includes a list of UITableViewCells. And I set the
I have a UITableView on a view. This UITableView has cells which are made
I have a custom UITableViewCell which has some subviews. i.e. some labels, some images.
In my app, I have a UITableView which has some custom cells and in
I have a subclassed UITableView, 'subclassChild' which inherits from another subclass 'subclassParent'. 'subclassParent' then
I have a UITableView in which of course I use some UITableViewCells. Now some
I have a UITableView in which each UITableViewCell having a UIView on them and
I have a UITableView made of static cells, and each cell contains a UILabel

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.