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
语句。但我无法让这些功能正常工作并为两者收到相同的错误消息。
更新计数
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")
}
}
加载动画
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
}