-0.4 C
New York
Saturday, February 22, 2025

ios – UIAlert is not going to dismiss when addAction used


I’m implementing a popUp alert message when synching information. It disappears when the synching course of is full as anticipated, however after I added a cancel button to the pop-up, the pop-up is not going to dismiss until activated by person. Additionally when the button is current the presentedViewController is not the alert (in accordance with the code test under), however it’s proven and lively to the person. After I omit the button, the code test under signifies it’s the presentedViewController. Any concepts?

DispatchQueue.principal.async {
    let alert = UIAlertController(title: "Syching Information", message: "This will take a number of seconds...", preferredStyle: .alert)
    //alert.addAction(UIAlertAction(title: "Cancel", fashion: .cancel, handler: nil)) // this prevents dismiss under
    alert.addAction(UIAlertAction(title: "Cancel", fashion: .default, handler: { (motion) in
        alert.dismiss(animated: true, completion: nil)}))
    print("** PRESENT Alert")
    self.current(alert, animated: true, completion: nil)
    //DispatchQueue.world().async { // runs sync in background - NOT wanted
    Activity {
        deviceSyncTime = 0 // non permanent bypass
        let zoneid = detZoneID(zName: fileC, zonesIn: privateZones)
        let chkDone = await fetchNewRecords(starttime: deviceSyncTime, db: db, zonename: zoneid)
        actLog(newPrint: "ManageF Cloud Information fetched:" + String(describing: chkDone.rely))
        let privateSync = await processSync3(db: db, recordA: recordsLoad, cloudStruct: chkDone)
        processTrigger = "On"
        updateFileZ3REM(newRecordUps: privateSync, dbase: db, inArray: recordsLoad)  {end in
            if end result == true {
                print("manageF, updateFileZ end result= true")
                DispatchQueue.principal.async {
                    if self.presentedViewController == alert {
                        alert.dismiss(animated: true, completion: nil)
                        print("** DISMISS referred to as")  // This executes when Cancel button is omitted
                    } else {
                        print("** ALERT is just not introduced controller") // This print is executed when Cancel button is current
                    }
                    print("** Attempting to dismiss alert controller")
                    alert.dismiss(animated: true, completion: nil) // This doesn't execute when Cancel button is current
                } // finish principal async
                if let findex = fileToBeUpdated.firstIndex(of: fileNN) {
                    fileToBeUpdated.take away(at: findex)
                }
            } else {
                print("manageF, updateFileZ end result= NOT true")
            }
        }
        print("finish process")
    } //finish process
    print("finish async op")
    //} // async
    print("finish principal thread")
} // principal thread

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles