Procházet zdrojové kódy

Fix view controller crash on load image

kevin před 5 měsíci
rodič
revize
6e260ec189

+ 15 - 5
AppBuilder/AppBuilder/ViewController.swift

@@ -1109,15 +1109,25 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
                                 let urlString = PrefsUtil.getURLBase() + "get_file_from_path?img=\(icon)"
                                 if let cachedImage = ImageCache.shared.image(forKey: urlString) {
                                     if i == 0 {
-                                      ViewController.chatButton.setBackgroundImage(cachedImage, for: .normal)
+                                        DispatchQueue.main.async {
+                                            ViewController.chatButton.setBackgroundImage(cachedImage, for: .normal)
+                                        }
                                     } else if i == 1 {
-                                      ViewController.callButton.setBackgroundImage(cachedImage, for: .normal)
+                                        DispatchQueue.main.async {
+                                            ViewController.callButton.setBackgroundImage(cachedImage, for: .normal)
+                                        }
                                     }  else if i == 2 {
-                                      ViewController.ccButton.setBackgroundImage(cachedImage, for: .normal)
+                                        DispatchQueue.main.async {
+                                            ViewController.ccButton.setBackgroundImage(cachedImage, for: .normal)
+                                        }
                                     }  else if i == 3 {
-                                      ViewController.postButton.setBackgroundImage(cachedImage, for: .normal)
+                                        DispatchQueue.main.async {
+                                            ViewController.postButton.setBackgroundImage(cachedImage, for: .normal)
+                                        }
                                     }  else if i == 4 {
-                                      ViewController.streamingButton.setBackgroundImage(cachedImage, for: .normal)
+                                        DispatchQueue.main.async {
+                                            ViewController.streamingButton.setBackgroundImage(cachedImage, for: .normal)
+                                        }
                                     }
                                     return
                                 }

+ 7 - 0
NexilisLite/NexilisLite/Source/View/Control/ChatWallpaperViewController.swift

@@ -86,8 +86,15 @@ class ChatWallpaperViewController: UIViewController, UICollectionViewDataSource,
             clearWallpaperButton.heightAnchor.constraint(equalToConstant: 50)
         ])
         
+        // Add a back button
+        let backButton = UIBarButtonItem(title: "Back", style: .plain, target: self, action: #selector(backButtonTapped))
+        navigationItem.leftBarButtonItem = backButton
         
     }
+    
+    @objc private func backButtonTapped() {
+        dismiss(animated: true)
+    }
 
     // MARK: - Collection View Data Source
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {