[英]How can I show table view cell values after click button?
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;
使用此方法
- (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?
我怎样才能做到这一点?
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. 保持表源等于nil,然后在按下按钮时将其设置为所需的值列表,然后重新加载表视图。
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 : 所以...如果您的表源是ivar NSArray * tableData,并且包含您的值的数组是ivar NSArray *值,那么在IBAction中,您应该执行以下操作:
-(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 就是这样
Have a private BOOL
property in your subclass of UITableViewController
that keeps track of whether or not the button has been pressed. 在
UITableViewController
的子类中有一个专用的BOOL
属性,该属性可跟踪是否已按下按钮。 Then, in tableView:CellForRowAtIndexPath:
load cells differently based on the value of that property. 然后,在
tableView:CellForRowAtIndexPath:
根据该属性的值不同地加载单元格。 When the property is set, call [self.tableview reloadData]
(capitalization might be wrong). 设置属性后,调用
[self.tableview reloadData]
(大写可能错误)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.