I'm using Fabric and TwitterKit to show a timeline at my Table View. At my code I'm using a dispatch_async function. I want to start the MBProgressHUD and after the timeline was loaded I want to disable the HUD. Unfortunately my HUD is appearing only for less than one second and the timeline is appearing about two seconds later. No matter how good or bad my internet connection is. I want to show the HUD as long as the timeline is loading.
This is my code:
override func viewDidLoad() {
super.viewDidLoad()
let ProgressHUD = MBProgressHUD.showHUDAddedTo(self.view, animated: true)
self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None
let client = TWTRAPIClient()
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0)) {
self.dataSource = TWTRUserTimelineDataSource(screenName: "fabric", APIClient: client)
self.showTweetActions = true
//Dark Timeline Theme
TWTRTweetView.appearance().theme = .Dark
TWTRTweetView.appearance().linkTextColor = UIColor.redColor()
dispatch_async(dispatch_get_main_queue()) {
ProgressHUD.hide(true)
}
}
}