ios - 检查 UIImageView 是否有动画

标签 ios iphone swift uiimageview

我目前正在开发一个允许用户选择个人资料图片的应用程序。

我可以选择图像并将其显示在 iPhone 屏幕上。我想确保用户在保存所有信息之前选择了图像。我已经做了一些研究,发现 isAnimating() 函数可以用来检查 UIImageView 实际上是在“动画化”/“显示”用户的图像。不幸的是,当我做检查时

        if profileImage.isAnimating() == true{

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

即使正在显示 profileImage ... isAnimating() 也始终返回 false。 :(

我不确定这个函数是否有问题,或者我们是否必须做其他事情。

任何帮助将不胜感激。 :(

最佳答案

你用错了方法。当 UIImageView 正在动画时,isAnimating 返回 YES。 UIImageView 允许您在一组 UIImages 之间设置动画

参见 the docs更多细节。

我认为您会想要使用 image 属性。如果为 nil,则没有设置图像。

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

关于ios - 检查 UIImageView 是否有动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28267246/

相关文章:

iphone - 我必须导入哪些框架才能使用音频队列服务和核心音频?

iphone - 单色触摸 : Enable Multisampling in OpenGL ES 2. 0

ios - 如何在代码中获取我的 iOS 项目的当前版本?

ios - 删除数组中的 View 和引用

jquery - PhoneGap/ Cordova : How to get use cookies (iOS)?

ios - 返回更高级别的 UITableView 时的 ViewDidLoad

swift - 字符串转十进制swift

objective-c - 谷歌加 iOS SDK : how to get logged in user email?

ios - dataSource 不会在 cellForItemAt 函数中更新

ios - 如何使用显示进度的 alamofire 上传多个文件?