简体   繁体   中英

MBProgressHUD with Swift, Fabric & TwitterKit

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)

        }
    }

}

I've done the same as:

MBProgressHUD.showHUDAddedTo(self.view, animated: true)  //for showing
MBProgressHUD.hideHUDForView(self.view, animated: true)  //for hiding

No need of that ProgressHud variable.

Well, i changed the framework to JGProgressHUD. It's working perfectly. No more problem here! Thank you for your help –

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM