How to refresh table's all cell's data on button click

Discussion in 'iOS Programming' started by rahul29tech, Apr 18, 2012.

  1. rahul29tech, Apr 18, 2012
    Last edited: Apr 18, 2012

    macrumors member

    Joined:
    Dec 22, 2011
    #1
    how to refresh table's cell when click on a button which is on another view,

    actully my table view is on a viewcontroller class and a button is on its subclass? now i want as button clicked which is on its subclass ,so subclass closed and data on super class's table is refreshed , how to do this????????



    i create a uiTableView object i.e

    this function is in superView which contain a table view :-
    Code:
    -(void) viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
        UITableView *tbv1=[[UITableView alloc] init];
        [tbv1 reloadData];    
    }
    this function is in my subView of above view i.e
    Code:
    -(IBAction) btn
    {
       [self.view removeFromSuperview];
    }
    

    so when this subView is removed from superview so my viewWillAppear method is not calling not executing and table is not reloaded????? suggest me what to do now????
     
  2. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    you can just make a reference in your header to your UITableView, and then call reloadData in there on your IBAction..
     
  3. macrumors 68040

    Joined:
    Apr 22, 2005
    #3
    The table view object you create and refer to in viewWillAppear is NOT the same table view that apparently appears in your app, which I'm guessing you added with interface builder.

    You need to connect the actual table view in your xib file to an IBOutlet that you create in your view controller subclass, and then use this instance variable to manipulate the table view. Literally any UITableView tutorial on the web will show you how to do this.
     
  4. thread starter macrumors member

    Joined:
    Dec 22, 2011
    #4
    yes sir u catch the exact problem,

    soo plz suggest me how can i make reference of that same table, so that i can reload the same table :( ??? how can i get or make reference of that same table ????

    m very new in iphone plz help me...m in this problem from last 48hrs
     
  5. thread starter macrumors member

    Joined:
    Dec 22, 2011
    #5
    m creating an iboutlet uitableview object attached it from my tableview in IB ,and then i will trying to reload that object even though it is not reloading table and not calling cellForRowAtIndexPath method while when reloading???


    now what to do i cant think , :mad: :(
     
  6. macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #6
    I think the problem is that reloadData does not call cellForRowAtIndexPath. I think I was having this problem as well.
     
  7. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    Sure it does.
     
  8. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #8
    Like Dejo said above me, ofcourse it does.. that's what it's for, it goes first to amount of rows it should reload, then load a cell for each item in the amount of rows..
     
  9. thread starter macrumors member

    Joined:
    Dec 22, 2011
    #9
    Problem solved...

    :):):) after 3 days i solved my problem thanks to all.....

    actually my viewWillAppear is not calling when i call removwFromSuperView method........so i have to push that page to call viewWillAppear method.....

    thanks every1 to help me
     
  10. macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #10
    To clarify, I would have thought that it did. Seems obvious. I must have been doing something wrong because I got it to work since then. At the time I had set breakpoints and was sure that it wasn't hitting CellForRowAtIndexPath. Everything is good now
     

Share This Page