Reputation: 175
I have a table view and it is load from table view cells. But I want to see this table's values after click a button.
With this method - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
,
I can see all data when view did load.
But firstly I dont want to see datas. I want to see thats after click a button. How can I do this?
Upvotes: 0
Views: 1734
Reputation: 6366
Have a private BOOL
property in your subclass of UITableViewController
that keeps track of whether or not the button has been pressed. Then, in tableView:CellForRowAtIndexPath:
load cells differently based on the value of that property. When the property is set, call [self.tableview reloadData]
(capitalization might be wrong).
Upvotes: 0
Reputation: 6397
Keep your table source equal to nil, then when the button is pressed set it to the list of values you need and reload the table view.
so ... if your table source is let's say the ivar NSArray* tableData, and the array with your values is the ivar NSArray* values then in your IBAction for your button you should do :
-(IBAction)buttonPressed:(id)sender
{
tableData = values; //load the values in the table source
[self.tableView reloadData]; //just call reloadData on the tableView
}
That's about it
Upvotes: 1