ui activity 指标没有出现在 viewcontroller 中,其中它有 table 视图和网页视图?

ui activity indicator is not showing up in viewcontroller, in which it has table view and web view?

var actInd: UIActivityIndicatorView = UIActivityIndicatorView()
 actInd.frame = CGRect(x: 0.0, y: 0.0, width: 40.0, height: 40.0)
   actInd.center = view.center
actInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.gray
 view.addSubview(actInd)
getinfo()
actInd.startAnimating()
func getinfo(){
 //in this function theres is few image parsing codes, for table view

for i in 0 ..< minuscurent1.count
    {
        let adict:NSDictionary = minuscurent1[i] as! NSDictionary

        let bdict:NSDictionary = adict.object(forKey: "snippet") as! NSDictionary
        let cdict:NSDictionary = bdict.object(forKey: "resourceId") as! NSDictionary
        let ddict:NSDictionary = bdict.object(forKey: "thumbnails") as! NSDictionary
        let edict:NSDictionary = ddict.object(forKey: "medium") as! NSDictionary

        self.videolist.add(bdict.object(forKey: "title") as! String)
        self.videoId.add(cdict.object(forKey: "videoId") as! String)
        self.image.add(edict.object(forKey: "url") as! String)
    }
DispatchQueue.main.async {
            self.actInd.stopAnimating()
            self.actInd.hidesWhenStopped = true
            self.videotable.reloadData()
        }

我希望 activity 指示器从头开始,当所有图像和网络视图都是 loaded.but activity 指示器未显示时结束它 up.i don不知道有什么问题 code.any 感谢帮助...

您的 image-loading 发生在 main-thread 中,因此阻止 UI 更新。您必须在后台线程中完成繁重的工作,并且只在完成后更新 activity-indicator。

DispatchQueue.global(qos: .background).async {
    // Background Thread
    // put your image loading here (for-loop)


    DispatchQueue.main.async {
        // Run UI Updates
        self.actInd.stopAnimating()
        self.actInd.hidesWhenStopped = true
        self.videotable.reloadData()
    }
}