简体   繁体   English

检查UIImageView是否正在设置动画

[英]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. 我可以选择图像并将其显示在iPhone屏幕上。 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. 我已经进行了一些研究,发现isAnimating()函数可用于检查UIImageView是否实际上是“动画” /“显示”用户的图像。 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. 即使profileImage正在显示... isAnimating()始终返回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动画时,isAnimating返回YES。 UIImageView allows you to animate between an array of UIImages UIImageView允许您在一组UIImages之间进行动画处理

see the docs for more details. 有关更多详细信息,请参阅文档

I think you will want to use the image property. 我认为您将要使用image属性。 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())
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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