Quote:
Originally Posted by CAM
Ok I have a tableView and a custom tableview cell. I created the class for the tableview cell. I can talk to the tableViewCell when i first create it with this code
I do this first
Code:
#import "tablecell.h"
then
Code:
tablecell *cell = [[tablecell alloc] init];
then
but i want to know when the user selects my button inside the cell and then notify my tableview. The only problem is i do not know how to talk to it without creating a new instance of the tableview class. This is what i am doing now that creates the new instance.
Code:
myTableViewClass *table = [[myTableViewClass alloc] init];
[table reloadDataFunction];
Is there anyway to access my already running tableview instance?
|
Your view controller should have an IBOutlet to the table view. Use that outlet to connect to the table view.
Also, quite a few of the table view methods (like tableView:didSelectRowAtIndexPath: ) pass you a pointer to the table view that needs attention. You can use that pointer to get to the table view.
As for how to get notified when the user clicks a button, you should connect an IBAction to your button that invokes a method in your view controller. Set a tag on the button based on the row of the cell. That way, in your IBAction method, you can use the button tag to tell which row of your table view the button belongs to.
Make sure you change the button tag in your cellForRowAtIndexPath method even if you get a recycled cell instead of creating a new one.