-1
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()

                    }

                }

        }

    }
Bannings
  • 10,376
  • 7
  • 44
  • 54
Liang
  • 281
  • 1
  • 3
  • 5

1 Answers1

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

Community
  • 1
  • 1
Warve
  • 481
  • 1
  • 8
  • 22
  • 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