我目前正在开发一个允许用户选择个人资料图片的应用程序。
我可以选择图像并将其显示在 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/