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

  • Home
  • SEARCH
  • 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 6043179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:52:16+00:00 2026-05-23T06:52:16+00:00

Hello guys i have cells in tableview, but there are two different UIButtons to

  • 0

Hello guys i have cells in tableview, but there are two different UIButtons to be assigned to cell. Depend on if the filename those cell indication is there in the sandbox.

i am doing this by following function while creating cell.

NSLog(@"%@", filepath);

        if ([[NSFileManager defaultManager] fileExistsAtPath:filepath]) 
        {
            [button setTitle:@"Submit" forState:UIControlStateNormal];
            [button addTarget:self action:@selector(SubmitData:) forControlEvents:UIControlEventTouchUpInside];
        }

        else
        {
            [button setTitle:@"Fetch" forState:UIControlStateNormal];
            [button addTarget:self action:@selector(FetchData:) forControlEvents:UIControlEventTouchUpInside];

        }

but the thing is that when i press Fetch button and when FetchData function is called, i fetch the data and save it in the sandbox. So i want to update the button to Submit as now the file is their.

So do i have to put something in FetchData function to update the cell button to Submit,

I tried using [self.tableview reloaddata];

but won’t update the cell.

FULL CODE

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *FirstLevelCell= @"FirstLevelCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:FirstLevelCell];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle  reuseIdentifier:FirstLevelCell] autorelease];
        NSDictionary * assignment = [assignments objectAtIndex:[indexPath row]];
        cell.textLabel.text= [NSString stringWithFormat:@"Riding Number is %@", [assignment objectForKey:@"Riding_Number"]];
        cell.detailTextLabel.text= [NSString stringWithFormat:@"Poll Number is %@",[assignment objectForKey:@"Poll"]];
        UIImage *buttonUpImage = [UIImage imageNamed:@"button_up.png"];
        UIImage *buttonDownImage = [UIImage imageNamed:@"button_down.png"];
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(0.0, 0.0, (buttonUpImage.size.width)*1.20,
                                  buttonUpImage.size.height);
        [button setBackgroundImage:buttonUpImage forState:UIControlStateNormal];
        [button setBackgroundImage:buttonDownImage forState:UIControlStateHighlighted];
          button.tag = [indexPath row];  
        NSString * filepath = [self dataFilePathwithFilename:[NSString stringWithFormat:@"%@_%@.plist",[assignment objectForKey:@"Riding_Number"],[assignment objectForKey:@"Poll"]]];


        if ([[NSFileManager defaultManager] fileExistsAtPath:filepath]) 
        {
            [button setTitle:@"Submit" forState:UIControlStateNormal];
            [button addTarget:self action:@selector(SubmitData:) forControlEvents:UIControlEventTouchUpInside];
        }

        else
        {
            [button setTitle:@"Fetch" forState:UIControlStateNormal];
            [button addTarget:self action:@selector(FetchData:) forControlEvents:UIControlEventTouchUpInside];

        }

        cell.accessoryView = button;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }

    // Configure the cell...

    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-23T06:52:16+00:00Added an answer on May 23, 2026 at 6:52 am

    set the closing } for if (cell == nil) right after cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:FirstLevelCell] autorelease];

    it says in your comment where you should configure the cell!.
    the if-not-nil statement is for creation only!! after this block you have to configure the cell (set texts, buttons, images, accessoryView, …). Just remember the cell could be in ANY state. When a cell leaves the visible area (topmost cell when you scroll down), it will be put in a pool where you grab it out again with dequeueReusableCellWithIdentifier and configure it to match the required index path (bottom cell that slides into the screen when you scroll down).

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

Sidebar

Related Questions

Hello guys I have the following method: var usuario; usuario = UniapontaService.GetUsuarioUniapontaPlanejamentoEstrategico(x => x.IdUsuario
Hello guys, I have an error I cannot solve, on a ASP.NET website. One
Hello guys, I have a general design problem with iPhone application. I want to
Hello guys sorry if the question looks stupid to you. i have 3 tables
Hello guys. I think it isn't possible just using PHP, but just to be
Hello guys I have a question regardless a old code a client needed a
Hello guys I have a function inside a utility class which returns the current
Hello guys i have an website online wich access the database. The database access
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello I am compiling a program with make but I get the error of

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.