简体   繁体   English

单击按钮后如何显示表格视图单元格的值?

[英]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.

相关问题 单击下一个视图控制器的按钮时,如何显示加载标签? - How can I get my loading label to show up when I click button to next view controller? 如何在按钮单击同一单元格内时隐藏/显示自定义tableview单元格内的特定视图 - how to hide/show a specific view inside the custom tableview cell when button click inside the same cell 当我单击垂直索引按钮时,表视图单元格中有按钮 - I have button in table view cell when I click the perticular index button state will change 在表格视图上单击按钮以更改表格视图单元格中的图像 - Button click on table view to change the image in my table view cell 如何使表格视图单元格作为按钮工作? - How do I make a table view cell work as a button? 在Objective-C中单击视图中的按钮后,如何按下标签栏控制器? - How can I push tab bar controller after click a button from a view in Objective-C? 表视图单元格作为按钮 - Table view cell as button 用户在表格视图单元格中单击自定义按钮时创建标签 - create a label when user click on the custom button in table view cell 如何在 iPhone 应用程序中设置表格视图单元格属性 - how can i set the table view cell property in an iphone app 如何通过单击单元格中央的按钮从uitableviewcell切换到另一个视图(通过prepareForSegue两个值) - How can I switch to another view (passing through prepareForSegue two values) from uitableviewcell by clicking a button in the center of the cell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM