class HomeViewController: UIViewController
{
// The timer is used to check when the download is complete and will only allow segues when it is
var timer = Timer()
var segueName: String = ""
static var didSelectTabBar = false
static var tabBarSegueName = ""
static var startAnimation: Bool = false
{
didSet
{
if startAnimation == true
{
updateCounting(<#T##HomeViewController#>)
loadAnimation(<#T##HomeViewController#>)
}
}
}
didSet
的变量正在单独的Swift文件中更改并且有效,我可以转到if
语句。但我无法使函数工作并为两者收到相同的错误消息。
updateCounting
func updateCounting(){
if MyVariables.allSoldiersDownloaded
{
HomeViewController.startAnimation = false
loadingImageView.stopAnimating()
loadingImageView.isHidden = true
if HomeViewController.didSelectTabBar == false
{
self.performSegue(withIdentifier: self.segueName, sender: nil)
}
timer.invalidate()
MyVariables().setGlobalSoldier(id: MyVariables.facebookSoldierID)
soldierOfHourButton.setTitle("Soldier of the Hour: \(MyVariables.globalSoldier.christian_names) \(MyVariables.globalSoldier.surname)", for: UIControlState.normal)
soldierOfHourButton.sizeToFit()
}
else {
//print("Not downloaded yet")
}
}
loadAnimation
func loadAnimation() {
//creates and stores all the names for the images used in an array
var imagesNames = ["run1-1.jpg", "run2-1.jpg", "run3-1.jpg", "run4-1.jpg", "run5-1.jpg", "run6-1.jpg", "run7-1.jpg", "run8-1.jpg", "run9-1.jpg", "run10-1.jpg", "run11-1.jpg"]
//create new uiimage array
var images = [UIImage]()
//loop through all the photos in the imagesNames array and add them to the images array
for i in 0..<imagesNames.count{
images.append(UIImage(named: imagesNames[i])!)
}
//tell testview what images to use for the animation
loadingImageView.animationImages = images
//tell testview how long to show a single image for
loadingImageView.animationDuration = 0.9
//start the animation in the image view called test view
loadingImageView.startAnimating()
loadingImageView.isHidden = false
}