Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 按下按钮时如何更改tableview中的数据_Objective C_Ios_Tableview - Fatal编程技术网

Objective c 按下按钮时如何更改tableview中的数据

Objective c 按下按钮时如何更改tableview中的数据,objective-c,ios,tableview,Objective C,Ios,Tableview,我有一个带有3个按钮的视图和一个tableview。当我按下按钮1时,按钮1后面的数据应该加载到tableview中。但当我按下按钮2时,按钮2后面的数据应该进入同一个表视图 如何实现这一点?只需将表视图的数据源切换到符合UITableViewDataSource的其他对象即可 -(void)pressedButton1 { self.tableView.dataSource = self.button1DataSource; [self.tableView reloadData

我有一个带有3个按钮的视图和一个tableview。当我按下按钮1时,按钮1后面的数据应该加载到tableview中。但当我按下按钮2时,按钮2后面的数据应该进入同一个表视图


如何实现这一点?

只需将表视图的
数据源切换到符合
UITableViewDataSource
的其他对象即可

-(void)pressedButton1
{
    self.tableView.dataSource = self.button1DataSource;
    [self.tableView reloadData];
}


-(void)pressedButton2
{
    self.tableView.dataSource = self.button2Source;
    [self.tableView reloadData];
}

只需将表视图的
dataSource
切换到符合
UITableViewDataSource
的其他对象

-(void)pressedButton1
{
    self.tableView.dataSource = self.button1DataSource;
    [self.tableView reloadData];
}


-(void)pressedButton2
{
    self.tableView.dataSource = self.button2Source;
    [self.tableView reloadData];
}

什么是self.button1和self.button2?他试图建议与这些按钮关联的数据源。什么是self.button1和self.button2?他试图建议与这些按钮关联的数据源。