Skip to content

Commit

Permalink
Start prefetcher and reload tableView of SwipeTableViewController pro…
Browse files Browse the repository at this point in the history
…perly regardless of the timings of loadDocument and viewDidLoad methods.
  • Loading branch information
Yoichi Tagaya committed Dec 14, 2016
1 parent 3538460 commit b7995fe
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions browser/SwipeTableViewController.swift
Expand Up @@ -65,7 +65,16 @@ class SwipeTableViewController: UIViewController, UITableViewDelegate, UITableVi
} else {
throw SwipeError.invalidDocument
}
callback(1.0, nil)

self.prefetcher.start { (completed:Bool, _:[URL], _:[NSError]) -> Void in
if completed {
MyLog("SWTable prefetch complete", level:1)
_ = self.view // Make sure the view and subviews (tableView) are loaded from xib.
self.prefetching = false
self.tableView.reloadData()
}
callback(self.prefetcher.progress, nil)
}
}

override func viewDidLoad() {
Expand All @@ -77,14 +86,6 @@ class SwipeTableViewController: UIViewController, UITableViewDelegate, UITableVi
effectView.autoresizingMask = UIViewAutoresizing([.flexibleWidth, .flexibleHeight])
imageView.addSubview(effectView)
}

self.prefetcher.start { (completed:Bool, _:[URL], _:[NSError]) -> Void in
if completed {
MyLog("SWTable prefetch complete", level:1)
self.prefetching = false
self.tableView.reloadData()
}
}
}

override func viewWillAppear(_ animated: Bool) {
Expand Down

0 comments on commit b7995fe

Please sign in to comment.