【发布时间】:2023-03-13 01:10:01
【问题描述】:
我正在开发一个包含多个视图的应用程序。每个视图包含几个由 UIImageView.animate 形成的动画。我遇到的问题是,每次我打开一个新的 View 内存并没有减少,在 iPhone 4 上增加到 320 Mb,retonrando 内存错误“由于内存错误而终止”。我找不到如何在 Swift 中自动释放内存,因为在 Objective-C 中,如果我能看到它更可取 imageWithContentOfFile 而不是命名:...
我使用它来将图像添加到 UIImage 对象:
var leftCorner: UIImage = UIImage(named: "navegacio_esquerra")!
要在 UIImageView.animationImages 中添加图像数组,我使用这个:
var thirdSisterHeadList: [Int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 33, 32, 33, 34, 33, 32, 33, 34, 33, 32, 33, 34, 33, 32, 33, 34, 33, 66, 67, 68]
var thirdSisterHeadImageList: [UIImage] = []
for i in thirdSisterHeadList{
var imageName = "pantalla_12_03_caps_c_\(i).png"
thirdSisterHeadImageList += [UIImage(named: imageName)!]
}
thirdSisterHead.animationImages = thirdSisterHeadImageList
【问题讨论】:
标签: ios swift uiimageview uiimage autorelease