I'm loading items from a web service to UITableView in an iOS application. The problem here is that as soon as the data gets loaded, the number of rows that are visible at top without scroll gets invisible. The page gets blank. If i scroll down, the images below gets loaded perfectly. On again scrolling up the top images also gets loaded properly.
Detailed Screenshot link: https://www.dropbox.com/sh/nfxcgw2ple8g4mt/AAAOTswWDEN-s2-dAbJ1bHu7a?dl=0
class FirstViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{
override func viewDidLoad() {
super.viewDidLoad()[1]
// self.client = xxxxxxxxxxxx;
//
// fetching from server logic query
//
//
query.readWithCompletion({ (result , error) -> Void in
if (error == nil)
{
self.activityIndicatorView.hidden = true // loading indicator
self.allResults = result.items
println( self.allResults!.count )
self.tableView.hidden = false
self.tableView.reloadData()
}
else{
println(error.localizedDescription) // error
}
})
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
if (allResults != nil) { return self.allResults.count }
else { return 0 }
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{ return 200 }
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
var cell: CellClass = self.tableView.dequeueReusableCellWithIdentifier("item") as! CellClass
return cell //typo
}