gpt4 book ai didi

ios - 通知中心 - 显示和隐藏启动栏

转载 作者:行者123 更新时间:2023-11-30 11:24:21 26 4
gpt4 key购买 nike

我有这个代码:

主视图 Controller :

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
// register notification
NotificationCenter.default.addObserver(self, selector: #selector(MainViewControler.StartUpdatingSplash), name: NSNotification.Name("updating.salestool"), object: nil)
}

@objc func StartUpdatingSplash() {
DispatchQueue.global().async {
EZLoadingActivity.show("LoadingMessage4".localized(), disableUI: true)
}
print("##### NOTIFICATION STEP: 1")
}

@objc func FinishUpdatingSplash() {
DispatchQueue.global().async {
EZLoadingActivity.hide()
}
NotificationCenter.default.removeObserver(self, name: Notification.Name("updating.salestool"), object: nil)
print("##### NOTIFICATION STEP: 2")
}

和 Config.swift:

NotificationCenter.default.post(name: NSNotification.Name("updating.salestool"), object: nil)

let dispatchImagesGroup = DispatchGroup()
dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: FileFolders.GET_PHOTO.rawValue, parametr: FileFolders.GET_PHOTO.rawValue)
dispatchImagesGroup.leave()
}

dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: FileFolders.GET_INSPIRATION_PHOTO.rawValue , parametr: FileFolders.GET_INSPIRATION_PHOTO.rawValue)
dispatchImagesGroup.leave()
}

dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: FileFolders.GET_PACKSHOT.rawValue , parametr: FileFolders.GET_PACKSHOT.rawValue)
dispatchImagesGroup.leave()
}


dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: (AppGlobalManager.sharedManager.loggedUser?.selectedLanguage)! + "/" + FileFolders.GET_TIPS_SLIDES.rawValue, parametr: FileFolders.GET_TIPS_SLIDES.rawValue)
dispatchImagesGroup.leave()
}

dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: (AppGlobalManager.sharedManager.loggedUser?.selectedLanguage)! + "/" + FileFolders.GET_LEAFLETS_SLIDES.rawValue, parametr: FileFolders.GET_LEAFLETS_SLIDES.rawValue)
dispatchImagesGroup.leave()
}

dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadImages(toDownloads: jsonData, savedURL: (AppGlobalManager.sharedManager.loggedUser?.selectedLanguage)! + "/" + FileFolders.GET_CONCEPTS_SLIDES.rawValue, parametr: FileFolders.GET_CONCEPTS_SLIDES.rawValue)
dispatchImagesGroup.leave()
}

dispatchImagesGroup.enter()
DispatchQueue.global().async {
self.downloadLeafletsPDF(toDownloads: jsonData, savedURL: (AppGlobalManager.sharedManager.loggedUser?.selectedLanguage)! + "/" + FileFolders.GET_LEAFLETS_PDF.rawValue)
dispatchImagesGroup.leave()
}

dispatchImagesGroup.notify(queue: .global()) {
NotificationCenter.default.addObserver(self, selector: #selector(MainViewControler.FinishUpdatingSplash), name: NSNotification.Name("updating.salestool.aviko.qbmobile.com"), object: nil)
}

StartUpdatingSplash - 运行启动画面。

函数 downloadImages - 运行从互联网下载照片的线程。启动后的应用程序会显示启动画面(EZLoadingActivity),然后下载照片。

我想在完成所有这些用于下载照片的线程后隐藏 EZLoadingActivity (EZLoadingActivity.hide),例如通过运行 FinishUpdatingSplash () 函数。我怎样才能做到这一点?

我的通知中心正确显示了启动画面 - 我有问题,只是隐藏它

最佳答案

在主异步队列中执行隐藏任务。

关于ios - 通知中心 - 显示和隐藏启动栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50924356/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com