UITableview Reload Data

Discussion in 'iPhone/iPad Programming' started by jjardim, Sep 23, 2010.

  1. macrumors newbie

    Joined:
    Mar 19, 2008
    Messages:
    26
    #1
    -iPad Application-
    I have a tableview with custom tableview cells with some dynamic data in it.

    Example
    Name
    Tasks 1 of 4 complete

    on the same screen I have a check box that completes the task. I am unable to get the tasks to change from 'Tasks 2 of 4 complete' unless I manually SCROLL the cell off the screen and then back on - I've tried [tableview reloadData] no luck. Is there a method to redraw the visible cells?

    Thanks!
    Jason Jardim
    www.MacSpots.com
     
  2. macrumors 6502a

    Joined:
    Nov 9, 2007
    Messages:
    706
    #2
    You can also use - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation but if reloadData isn't working then I'm not sure that will either.

    Is the cell that displays "x of y tasks complete" a custom subclass of UITableViewCell or are you using one of the built-in styles?
     
  3. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Messages:
    15,045
    Location:
    The Centennial State
    #3
    reloadData should do the trick. In fact, it really only reloads visible cells. But perhaps some code, especially your tableView:cellForRowAtIndexPath:, would better help us diagnose.
     
  4. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    Messages:
    2,675
    #4
    If you look at Apple's tableViewSuite sample code it does some things like this. One of the examples shows the time zones around the world and displays an icon that indicates whether it's day or night at each location and updates this dynamically as time changes.
     
  5. macrumors regular

    Joined:
    Aug 26, 2010
    Messages:
    223
    #5

    Normally you want to use reloadRowsAtIndexPaths:withRowAnimation:. Tableview reloadData redraws all visible views which can be heavy. However if you are not getting the update with reloadData, reloadRowsAtIndexPaths will not help. How exactly are you updating your datasource.

    umm just a shot in the dark but but are you doing [tableView reloadData] or [self.tableView reloadData].

    Also make sure you're updating the dataSource before reloading the table.
     

Share This Page