table 在 getCArrayList 方法中调用函数 reloaddata() 时视图未重新加载
table view is not reloading when calling function reloaddata() inside getCArrayList method
func getCArrayList(id:String, array:[NSDictionary] ){
videolist = NSMutableArray()
videoId = NSMutableArray()
image = NSMutableArray()
for i in 0 ..< array.count
{
let adict:NSDictionary = array[i] as! NSDictionary
let bdict:NSDictionary = adict.object(forKey: "snippet") as! NSDictionary
let cdict:NSDictionary = bdict.object(forKey: "resourceId") as! NSDictionary
let ddict:NSDictionary = bdict.object(forKey: "thumbnails") as! NSDictionary
let edict:NSDictionary = ddict.object(forKey: "medium") as! NSDictionary
self.videolist.add(bdict.object(forKey: "title") as! String)
self.videoId.add(cdict.object(forKey: "videoId") as! String)
self.image.add(edict.object(forKey: "url") as! String)
if videoId[i] as! String == id {
self.videolist.remove(i)
self.videoId.remove(i)
self.image.remove(i)
}
}
self.videotable.reloadData()
}
//calling the fuction:
getCArrayList(id: videoid, array: didselectarray)
调用函数getCArrayList时,tableview没有重新加载
在 tableview 方法 didselectrowatindexpath() 中调用函数
我哪里做错了?感谢您的帮助....
请尝试以下操作:
DispatchQueue.main.async {
self.videotable.reloadData()
}
希望对您有所帮助。
func getCArrayList(id:String, array:[NSDictionary] ){
videolist = NSMutableArray()
videoId = NSMutableArray()
image = NSMutableArray()
for i in 0 ..< array.count
{
let adict:NSDictionary = array[i] as! NSDictionary
let bdict:NSDictionary = adict.object(forKey: "snippet") as! NSDictionary
let cdict:NSDictionary = bdict.object(forKey: "resourceId") as! NSDictionary
let ddict:NSDictionary = bdict.object(forKey: "thumbnails") as! NSDictionary
let edict:NSDictionary = ddict.object(forKey: "medium") as! NSDictionary
self.videolist.add(bdict.object(forKey: "title") as! String)
self.videoId.add(cdict.object(forKey: "videoId") as! String)
self.image.add(edict.object(forKey: "url") as! String)
if videoId[i] as! String == id {
self.videolist.remove(i)
self.videoId.remove(i)
self.image.remove(i)
}
}
self.videotable.reloadData()
}
//calling the fuction:
getCArrayList(id: videoid, array: didselectarray)
调用函数getCArrayList时,tableview没有重新加载 在 tableview 方法 didselectrowatindexpath() 中调用函数 我哪里做错了?感谢您的帮助....
请尝试以下操作:
DispatchQueue.main.async {
self.videotable.reloadData()
}
希望对您有所帮助。