class DropTvViewController: UIViewController , UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
var dataTransfer = DataTransfer()
var responseString : String = ""
let storeData = StoreData()
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
let pfod = PostForData()
pfod.forData
{ jsonString in
self.responseString = jsonString as String
var dict = self.dataTransfer.jsonToArray(self.responseString)!
if let x: AnyObject = dict.valueForKey("readlist")
{
println( dict.count )
println("X + \(x)")
for var i = 0 ; i < dict.count-1 ; i+=2
{
println("i : \(i)")
let y: AnyObject = x.objectAtIndex(i)
let z: AnyObject? = y.objectForKey("epipic")
let title : AnyObject? = y.objectForKey("epititle")
let time : AnyObject? = y.objectForKey("droptagcreatetime")
let pg : AnyObject? = y.objectForKey("pgname")
var imagessss = UIImage (data : pfod.forPicture())
self.storeData.add(title as! String, aFs: pg as! String, aTs: time as! String, ph: imagessss! , field1s: z as! String, field2s: z as! String, field3s: z as! String, field4s: z as! String )
// I do reload in here,but it will delay about ten seconds.
// I am sure the data is ready to read
self.tableView.reloadData()
}
}
}
}
Asked
Active
Viewed 1,980 times
-1
-
why are you reloading in the loop ? this will reload all the cells in the table view. Move this statement outside the loop – Inder Kumar Rathore Jul 14 '15 at 05:29
-
I move it out . Thanks for your notification – Liang Jul 14 '15 at 06:29
1 Answers
0
You can use self.tableView.reloadData() which you are doing, but just in the wrong part of the loop. Just move it outside and you should be fine :)
If you're looking to reload a specific table cell then try: self.tableView.reloadRowsAtIndexPaths(paths, withRowAnimation: UITableViewRowAnimation.None)
Answer taken from here: https://stackoverflow.com/a/26709571/4891259
-
I move it out of loop,but it still delay for a long time. I post my data with Http Post asynctask ,would it be a problem for delay? – Liang Jul 14 '15 at 07:37
-
How does the task perform outside the app, are you sure this is iOS related and not the hosted server?? – Warve Jul 14 '15 at 16:46
-
I am sure data is back to my app,but data does not reload and show on screen immediately. – Liang Jul 15 '15 at 01:13