[tableView reloadData]; doesn't work until I scroll the tableView

后端 未结 5 1863
南方客
南方客 2021-02-01 18:57

I have a simple app that downloads search results in XML when the user types in a UISearchBar. The download+parsing is threaded and once done it fires an NSNo

5条回答
  •  一个人的身影
    2021-02-01 19:50

    My problem was that I was posting a NSNotification from a background thread. To avoid this, simply wrap your postNotificationMethod in a dispatch_async method like this:

    dispatch_async(dispatch_get_main_queue(), ^{
        [[NSNotificationCenter defaultCenter] postNotificationName:@"FinishedDownloading" object:result];
    });
    

    When this notification will be received, the tableView.reloadData will be called on the main thread.

提交回复
热议问题