简体   繁体   中英

Updated to Xcode 7.1 (from 6.4) caused UIIMageView animation broken

I upgraded my Xcode project that has been compiling just fine in 6.4 and choose not to upgrade to Swift 2.0 (I want to get it to compile first before causing more errors).

I got hundreds of errors, most have been fixed now, but I can't figure this one out. This has been working in 6.4:

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

I get the error in 7.1.1:

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

If I try the compilers suggestion I get this:

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

That gives me the error:

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

What you have to do is declare imgListArray as array of images. Here is how to do that:

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

Here's how I fixed your error:

   var imgListArray = [AnyObject]()
        self.imageView.animationImages = imgListArray as! [UIImage]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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