我目前正在开发一个允许用户选择个人资料图片的应用程序。
我可以选择图像并在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。 :(
我不确定此功能是否有问题,或者我们是否需要做其他事情。
任何帮助都将非常感激。 :(
答案 0 :(得分:1)
您使用了错误的方法。当UIImageView是动画时,isAnimating返回YES。 UIImageView允许您在UIImages数组之间设置动画
有关详细信息,请参阅the docs。
我想你会想要使用image
属性。如果它为零,则表示没有设置图像。
if profileImage.image { // nil evaluates to false
self.user.save()
self.performSegueWithIdentifier("moveToMainScreen", sender: self)
} else {
println("please select an image")
// println(profileImage.isAnimating())
}