简体   繁体   中英

Checking if UIImageView is animating

i am currently working on an application that allows the user to select a profile image.

I am able to select the image and display it on the iPhone screen. I want to make sure that the user has selected an image before saving all his information. I have have done some research around and have found that isAnimating() function can be used to check that the UIImageView is actually "animating"/"displaying" the user's image. Unfortunately, when I do the check

        if profileImage.isAnimating() == true{

             self.user.save()
            self.performSegueWithIdentifier("moveToMainScreen", sender: self)
        } else {
            println("please select an image")
            println(profileImage.isAnimating())
        }

Even if profileImage is displaying ... isAnimating() always returns false. :(

I'm not sure if there is something faulty with this function or if we have to do something else.

Any help will be really appreciated. :(

You're using the wrong method. isAnimating returns YES when a UIImageView is, well, animating. UIImageView allows you to animate between an array of UIImages

see the docs for more details.

I think you will want to use the image property. If its nil, then no image has been set.

    if profileImage.image { // nil evaluates to false
        self.user.save()
        self.performSegueWithIdentifier("moveToMainScreen", sender: self)
    } else {
        println("please select an image")
        // println(profileImage.isAnimating())
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM