Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.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
Iphone 在UITableViewController中对行进行排序_Iphone_Ios_Ipad_Sorting_Uitableview - Fatal编程技术网

Iphone 在UITableViewController中对行进行排序

Iphone 在UITableViewController中对行进行排序,iphone,ios,ipad,sorting,uitableview,Iphone,Ios,Ipad,Sorting,Uitableview,我有一个UITableViewController,其中包含一些非常基本的数据。假设每行只包含一个随机整数。我想对这些行进行排序(升序或降序都可以)。我有一个“Sort”按钮和一个“sortItems”委托,当点击Sort按钮时会调用它如何对UITableViewController的内容进行排序并更新显示?如果有帮助,我还会将UITableViewController中显示的数据存储在数组中 干杯 与UITableViewController关联的数据源是您在单元格中显示的数据的主要访问点 我

我有一个UITableViewController,其中包含一些非常基本的数据。假设每行只包含一个随机整数。我想对这些行进行排序(升序或降序都可以)。我有一个“Sort”按钮和一个“sortItems”委托,当点击Sort按钮时会调用它如何对UITableViewController的内容进行排序并更新显示?如果有帮助,我还会将UITableViewController中显示的数据存储在数组中


干杯

与UITableViewController关联的数据源是您在单元格中显示的数据的主要访问点

我不知道您的数据模型是什么样子,但这可能很简单,就像对数据源中存储的整数数组(在您的示例中)进行排序一样

当我说“数据源”时,我的意思是:实现


因此,对模型进行排序,然后在
tableViewController.tableView中
重新加载数据。tableView
假设在数组中保存了整数,对其进行排序,然后使用它通过自定义来填充tableView

- (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath 

要在单元格i中填充
sortedInts[i]

您可以将单元格的代码发布到Rowatindexpath吗?谢谢您的回复!我只是不知道重载数据的方法。