Dancer
Dancer

Reputation: 17651

iOS - Access custom UITableViewCell property from another ViewController.

The main view of an iOS App, I'm currently working on is a UITableViewController (mainHp_TVC) containing several custom UITableViewCells.

I need to access one of these uiTableViewCells from a different UIViewController - as it basically has a count button that I need to hide, but i'm struggling and can't find any info to guide me.

How can I access this cell? It is the first cell in the UITableViewController and only used in one instance and its class is HP_Header_TableViewCell

I have included both mainHp_TVC.h and HP_Header_TableViewCell.h and created an instance as follows -

HP_Header_TableViewCell *hpTC;
hpTC.msgsBtn.hidden = true;

But, I can't access the button property with the above - can anyone point me in the correct. direction?

Upvotes: 1

Views: 338

Answers (1)

sage444
sage444

Reputation: 5684

If you sure that cell can be only in one instance, make property in view controller that holds table, and assign this cell when create it.

Latter in another controller you need link to mainHp_TVC instance to access cell;

BUT in general is bad idea, the right way is change data that fills table, and call reloadData in table to get refreshed UI.

Also please check comment from @danh

Upvotes: 2

Related Questions