ios - 更新到 Xcode 7.1(从 6.4)导致 UIIMageView 动画损坏

标签 ios swift uiimageview xcode6 xcode7

我升级了我的 Xcode 项目,该项目在 6.4 中编译得很好,但选择不升级到 Swift 2.0(我想先编译它,然后再导致更多错误)。

我遇到了数百个错误,现在大部分都已修复,但我无法弄清楚这一错误。这在 6.4 中一直有效:

var imgListArray:NSMutableArray = []
self.imageView.animationImages = imgListArray as [AnyObject]

我在 7.1.1 中得到错误:

'NSMutableArray' is not implicitly convertible to '[AnyObject]'; did you mean to use 'as' to explicitly convert?

如果我尝试编译器的建议,我会得到:

self.imageView.animationImages = imgListArray as [AnyObject] as [AnyObject]

这给了我错误:

Cannot assign value of type '[AnyObject]' to type '[UIImage]?'

最佳答案

您需要做的是将 imgListArray 声明为图像数组。 以下是如何做到这一点:

var imgListArray: [UIImage] = []
self.imageView.animationImages = imgListArray

关于ios - 更新到 Xcode 7.1(从 6.4)导致 UIIMageView 动画损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33832687/

相关文章:

ios - 根据屏幕大小设置 UIStackView 轴

ios - 为什么 GMSMapView 没有设置在适当的坐标?

ios - 取消按钮在自定义操作表中不可点击

ios - 旋转 UIImage

iphone - 从 appdlication 中的缓存目录加载图像在 App 委托(delegate)中完成方法

ios - Swift UIImageView 始终为空

ios - sender.selected = ! sender.selected 在选定状态之间切换?

objective-c - iOS Mediaplayer 和 URL 重定向

ios - 如何使用 JSQMessagesViewController 发送图片?

objective-c - 如何更改 SFSafariViewController 工具栏颜色