Refresh A View?

Discussion in 'iOS Programming' started by JoshAK, Dec 9, 2008.

  1. JoshAK macrumors newbie

    Aug 12, 2008
    I'm working on a simple app that uses a <UITabBarDelegate> and int value.

    When the user clicks a button I want to change the value using "++value" and then refresh my view with an if ( value == x). Everything works except I'm unable to refresh or reload the view data. Please help.

    I've got this one fixed. Thanks anyway.
  2. sergio27 macrumors member

    Nov 2, 2008
    Hi. Good to hear you found your answer. Would you share what you did?

    I'm having a similar problem, and I think the solution may be the same. I'm trying to refresh the content on a TableView when I click a button, but when I call the reloadData method nothing happens.
  3. JoshAK thread starter macrumors newbie

    Aug 12, 2008
    Refresh Table View?


    I was trying to refresh a UIView not a UITableView. Can you post your
    Data To Refresh

    I'll take a look at it. Also, why are you trying to refresh a table view? Is it due to added or deleted table rows? Or new downloaded data source? I need to know more in order to help. Thanks.
  4. sergio27 macrumors member

    Nov 2, 2008
    Thanks for your interest, Josh. I had not been able to reply until now.

    I have a Text Field, a Button and a Table View. I want the user to write something in the Text Field, click on the Button, and the content of the Text Field to be added to the Table View.

    This is the button method:

    -(IBAction)add:(id)sender {
    EstadosAppDelegate *appDelegate = (EstadosAppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDelegate.states addObject:textInput.text];
    [tableView reloadData];
    [button setTitle:mad:"Added" forState:UIControlStateNormal];

    The title of the button is changed to " Added", but the Table View data is not realoaded. The Table View data is correctly linked to the "states" array. Using the same instructions on the didSelectRowAtIndexPath, the data is reloaded.

    I hope you can help me. Thank you.
  5. russellelly macrumors regular

    Jun 23, 2006
    Glasgow, UK
    I don't have an answer, as I'm having a similar issue, but the API for reloadData states: "the table view redisplays only those rows that are visible" ... "It should not be called in the methods that insert or delete rows,". So I don't think that's the correct call to make.

    – insertRowsAtIndexPaths:withRowAnimation:
    – insertSections:withRowAnimation:
    – deleteRowsAtIndexPaths:withRowAnimation:
    – deleteSections:withRowAnimation:

    may be more appropriate? They're not enough for my needs, as I want to be able to reload all the local state in the TableView (which is loaded from a sqlite DB) on certain events.

Share This Page