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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:10:31+00:00 2026-05-24T11:10:31+00:00

I have an application that contains 4 mutable arrays,i already displays one array of

  • 0

I have an application that contains 4 mutable arrays,i already displays one array of items in tableview cell,but i want to change the contents of the table cells in button click,i defined 4 buttons ,my need is when i click a button the tableview cells changes the array and display corresponding array items.I this possible to reuse tableview cell in a button click,my code for tableview cell below.

#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
    // Return the number of sections.
    return 1;
}


- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [_titleArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    // Each subview in the cell will be identified by a unique tag.
    static NSUInteger const kcatogeryLabelTag = 2;
    static NSUInteger const ktitleLabelTag = 3;
    static NSUInteger const kshortDiscriptionLabelTag = 4;
    static NSUInteger const knewsImageTag = 5;

    // Declare references to the subviews which will display the earthquake data.
    UILabel *catogeryLabel = nil;
    UILabel *titleLabel = nil;
    UILabel *shortDiscriptionLabel = nil;
    UIImageView *newsImage = nil;

    static NSString *kEarthquakeCellID = @"EarthquakeCellID";    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kEarthquakeCellID];
    if (cell == nil) {
        // No reusable cell was available, so we create a new cell and configure its subviews.
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                       reuseIdentifier:kEarthquakeCellID] autorelease];

        catogeryLabel = [[[UILabel alloc] initWithFrame:CGRectMake(91, 3, 190, 20)] autorelease];
        catogeryLabel.tag = kcatogeryLabelTag;
        catogeryLabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:20];
        [cell.contentView addSubview:catogeryLabel];

        titleLabel = [[[UILabel alloc] initWithFrame:CGRectMake(91, 28, 170, 14)] autorelease];
        titleLabel.tag = ktitleLabelTag;
        titleLabel.font = [UIFont fontWithName:@"Manorama" size:10];
        [cell.contentView addSubview:titleLabel];

        shortDiscriptionLabel = [[[UILabel alloc] initWithFrame:CGRectMake(91, 50, 500, 20)] autorelease];
        shortDiscriptionLabel.tag = kshortDiscriptionLabelTag;
        shortDiscriptionLabel.font = [UIFont fontWithName:@"Manorama" size:14];
        shortDiscriptionLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
        [cell.contentView addSubview:shortDiscriptionLabel];

        newsImage = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"loadingimage.jpg"]] autorelease];
        CGRect imageFrame =newsImage.frame;
        imageFrame.origin = CGPointMake(62, 2);
        newsImage.frame = imageFrame;
        newsImage.tag = knewsImageTag;
        newsImage.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
        [cell.contentView addSubview:newsImage];
    } else {
        // A reusable cell was available, so we just need to get a reference to the subviews
        // using their tags.
        //
        catogeryLabel = (UILabel *)[cell.contentView viewWithTag:kcatogeryLabelTag];
        titleLabel = (UILabel *)[cell.contentView viewWithTag:ktitleLabelTag];
        shortDiscriptionLabel = (UILabel *)[cell.contentView viewWithTag:kshortDiscriptionLabelTag];
        newsImage = (UIImageView *)[cell.contentView viewWithTag:knewsImageTag];
    }


    // Get the specific earthquake for this row.
    Row *newsSubcatogery = [_titleArray objectAtIndex:indexPath.row];

     // Set the relevant data for each subview in the cell.
      catogeryLabel.text = newsSubcatogery.categoryName; 

      titleLabel.text =  newsSubcatogery.title;

      shortDiscriptionLabel.text =   newsSubcatogery.shortDescription;

      NSURL *url = [NSURL  URLWithString:newsSubcatogery.thumbImage];
      NSData *data = [NSData dataWithContentsOfURL:url];
      UIImage *image = [[UIImage alloc] initWithData:data]; 
     // CGSize imageSize = [image size];
      [newsImage setImage:image];
      [image release], image = nil;

     return 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-05-24T11:10:32+00:00Added an answer on May 24, 2026 at 11:10 am

    you have to assigned tag property of table view on your button click.

    - (IBAction) btnClick1:(id)sender
    {
       tableview.tag = 200;
       [tableview reload];
    }
    

    now in all your table view’s delegate method check the tag of table view like

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    {
        if([tableView tag] == 200)
        {
            return [otherArray count];
        }
        else if ([tableView tag] == 300)
        {
            return [anotherArray count];
        }
    }
    

    above is sample code you have to modify it accordingly. Hope it helps you.

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

Sidebar

Related Questions

I have a Qt application that contains a QTreeWidget. I want to replace one
I have one application that contains sub-applications. I would like to segregate the GIN
I have Java Desktop application that displays some information in a JTable that contains
Essentially what I want to do is have a root application.haml that contains the
I currently have a single solution that contains both the one application developed so
I have an application that contains many controls on a panel, each with its
I have an application that contains a VC++ project (along with C# projects). Previously,
We have a windows application that contains an ActiveX WebBrowser control. As part of
I have a console application that contains quite a lot of threads. There are
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is

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.