出于某种原因,当我点击我的chooseButton时,SVProgressHUD将不会显示。选择chooseButton后,将显示一个新视图。当我按下并再次按下chooseButton时,它会正确显示SVProgressHUD。我想知道如何解决这个问题,这样当我第一次触摸chooseButton时它会显示SVProgressHUD,而不仅仅是当我按下并第二次加载视图时。
class ChooseLocationVC: UIViewController{
@IBAction func chooseButton(_ sender: Any) {
SVProgressHUD.show()
if pageControl.currentPage == 0{
SVProgressHUD.show()
Global.Location = "Los Angeles"
Global.usersListSent = usersLA
print("LA")
}
else if pageControl.currentPage == 1{
SVProgressHUD.show()
Global.Location = "San Francisco"
Global.usersListSent = usersSF
print("SF")
}else if pageControl.currentPage == 2{
SVProgressHUD.show()
Global.Location = "New York"
Global.usersListSent = usersNY
print("NY")
}else if pageControl.currentPage == 3{
Global.Location = "Miami"
Global.usersListSent = usersMiami
print("Miami")
}else if pageControl.currentPage == 4{
SVProgressHUD.show()
Global.Location = "Las Vegas"
Global.usersListSent = usersLV
print("LasVegas")
}else if pageControl.currentPage == 5{
Global.Location = "Chicago"
Global.usersListSent = usersChi
print("Chicago")
}
}
class PagesCollectionViewController: UICollectionViewController {
override func viewDidLoad() {
super.viewDidLoad()
SVProgressHUD.dismiss()
}
func firebaseCallCompleted(data: AnyObject?, isSuccess: Bool, error: Error?, type: FirebaseCallType) {
if(type == .ListByLocation) {
if(isSuccess) {
self.userArray.removeAll()
self.images.removeAll()
self.images.removeAll()
if(data != nil) {
let dataDict = data as! NSDictionary
let keyArray = dataDict.allKeys
for i in 0 ..< keyArray.count {
var dict = NSDictionary()
dict = dataDict.object(forKey: keyArray[i]) as! NSDictionary
self.userArray.append(Users.init(data: dict))
}
}
self.collectionView?.reloadData()
SVProgressHUD.dismiss()
}
else {
print(error?.localizedDescription)
SVProgressHUD.dismiss()
}
}
}