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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:50:14+00:00 2026-05-25T05:50:14+00:00

I have two questions about content view. 1st question: There are two content views

  • 0

I have two questions about content view.

1st question:
There are two content views in tableview cell. How do I know which one is touched?

2nd question:
I only want content view to appear in the first section of the tableview.
But, when I scroll up tableview, content view appears in the third section also.
How can I fix this problem?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{       
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];   

    UIImageView *imgView, *imgView1;   
    if(cell == nil)   
    {
       if (indexPath.section == 0) {
           cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];     
           cell.textLabel.text = @"test";

           imgView = [[UIImageView alloc] initWithFrame:CGRectMake(100,0,20,62)];
           [imgView setImage:[UIImage imageNamed:@"1.png"]];
           imgView.tag = 10;
           [cell.contentView addSubview:imgView];
           [imgView release];

           imgView1 = [[UIImageView alloc] initWithFrame:CGRectMake(200,0,20,62)];
           [imgView1 setImage:[UIImage imageNamed:@"2.png"]];
           imgView1.tag = 20;
           [cell.contentView addSubview:imgView1];
           [imgView1 release];
       }
    }   
    else
    {
        if (indexPath.section == 0) {
           imgView = (id)[cell.contentView viewWithTag:10];
           imgView1 = (id)[cell.contentView viewWithTag:20];
        }
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    // How do I know left content view is touched or right content view is touched?
}
  • 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-25T05:50:14+00:00Added an answer on May 25, 2026 at 5:50 am

    1) You can add different recognizers to each view which will call different methods.

    // create view
    UIImageView *view = [UIImageView ...];
    view.userInteractionEnabled = YES;
    // create recognizer
    UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myViewTapped:)];
    // add recognizer to your view
    [view addGestureRecognizer:recognizer];
    [recognizer release];
    // now when user will tap on your view method - (IBAction)myViewTapped:(UIGestureRecognizer); will be called
    

    2) As you are reusing cell, don’t forget to nil or remove from content view unneedfull views (as they already been added in previous section and reused in third one).

    UIView *view2remove = [cell viewWithTag:itsTag];
    [view2remove removeFromSuperview];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two questions about java.awt.Shape . Suppose I have two Shape s, shape1
So I have two questions about HashMap s in Java: What is the correct
I have two noobish questions about Flash, Actionscript, Flex etc. 1) With these technologies
I have two examples I have a question about. Let me explain via some
I have a question about how to set up the relations between two models
I have a question about the singleton pattern. I saw two cases concerning the
Question I have two compilers on my hardware C++ and C89 I'm thinking about
I have a generic question about scope and encapsulation. Take two scenarios: Scenario 1:
I have two questions: 1) How can I make an array which points to
I have just asked these two questions, one on flash seo url best practices

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.