Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.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/7/sqlite/3.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
Arrays 下载远程映像后延迟数据源方法_Arrays_Swift_Model View Controller_Koloda - Fatal编程技术网

Arrays 下载远程映像后延迟数据源方法

Arrays 下载远程映像后延迟数据源方法,arrays,swift,model-view-controller,koloda,Arrays,Swift,Model View Controller,Koloda,我正在使用这个图书馆 基本上,这是一个pod,可以帮助我实现一个类似Tinder的滑动界面 此pod有一个名为kolodaNumberOfCards(koloda:KolodaView)的数据源方法,该方法要求您声明程序希望在koloda视图中显示多少张卡 func kolodaNumberOfCards(_ koloda: KolodaView) -> Int { return allCards.list.count } 我在我的应用程序中实现了一个MVC架构,因此我在

我正在使用这个图书馆 基本上,这是一个pod,可以帮助我实现一个类似Tinder的滑动界面

此pod有一个名为
kolodaNumberOfCards(koloda:KolodaView)
的数据源方法,该方法要求您声明程序希望在koloda视图中显示多少张卡

func kolodaNumberOfCards(_ koloda: KolodaView) -> Int {
        return allCards.list.count
}
我在我的应用程序中实现了一个MVC架构,因此我在当前视图控制器的顶部实例化了一个数据模型类文件

var allCards = QuestionBank()
问题库
类中,我有一个列表(数组)中的
对象,其中包含
对象的所有元数据<代码>卡片对象还包含我要在KolodaCard视图中实例化的UIImage

当我在init的QuestionBank列表数组中没有卡对象时,问题就出现了!这些
Card
对象在我从API远程获取数据后附加到列表中

但是,在包含Koloda视图的ViewController中,我需要声明程序希望在Koloda视图中显示的卡片数量。由于当您第一次进入ViewController时,list.count为0,因此KolodaView预期为0卡

目前我的KolodaView没有显示我下载的任何图像


有没有办法延迟Koloda的数据源方法,以便程序可以等待从API获取所有数据,或者有没有其他解决方案

没有必要拖延。获取远程数据并更新数据模型后,调用视图提供的任何API来重新加载它(类似于
UITableView reloadData
。我需要声明有多少张卡,但在开始时列表中没有元素,因此程序假设Koloda视图中将有0张卡?让它从0开始。一旦数据更新并重新加载数据,它将返回up注明日期的号码。