-1
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
}
4

2 回答 2

1

欢迎来到 SO。请提供尽可能多的信息(例如完整的堆栈跟踪),并正确格式化您的问题(请参阅我的编辑)。这样,您将更快地获得帮助。

是什么意思<#T##HomeViewController#>

它应该只是updateCounting() and loadAnimation()

操场

于 2017-03-13T00:07:56.207 回答
0

代替

        updateCounting(<#T##HomeViewController#>)
        loadAnimation(<#T##HomeViewController#>)

        updateCounting()
        loadAnimation()
于 2017-03-13T00:05:41.847 回答