gpt4 book ai didi

ios - 字符串(格式 :) Crashes in iOS 7 - Need an alternative. 线程 1 : EXC_BAD_ACCESS (code=1, 地址=0x10)

转载 作者:可可西里 更新时间:2023-11-01 01:40:47 25 4
gpt4 key购买 nike

String(format:) 方法使我的应用程序在 iOS 7 中崩溃,但它在 iOS 8 中运行良好。有什么我可以用来在此处获得相同效果的方法吗?

我收到的错误消息是:THREAD 1: EXC_BAD_ACCESS (code=1, address=0x20)只有 (lldb)在控制台中。

我在所有 7.1 模拟器设备和 iPhone 4 7.1.2 设备上遇到此错误。

func configureLoadingIcon() {
loadingImage.alpha = 0.0
loadingImage.animationImages = [UIImage]()
for var index = 0; index < 48; index++ {

// Need an alternative to this line
var frameName = String(format: "loading_%05d", index)

loadingImage.animationImages?.append(UIImage(named: frameName)!)
}
loadingImage.animationDuration = 1.3
loadingImage.startAnimating()
}

//编辑

我现在正在做这个......但在 iOS 7 上仍然没有乐趣......

func configureLoadingIcon() {
loadingImage.alpha = 0.0
loadingImage.animationImages = [UIImage]()
var frameName: String
for var i = 0; i < 48; i++ {
let formatter = NSNumberFormatter()
formatter.minimumIntegerDigits = 2
let formattedIndex = formatter.stringFromNumber(i)
var frameName = String(format: "loading_000%@", formattedIndex!)
loadingImage.animationImages?.append(UIImage(named: frameName)!)
}
loadingImage.animationDuration = 1.3
loadingImage.startAnimating()
}

我也试过var frameName = "loading_000\(formattedIndex)"但这似乎不起作用.. 不确定为什么。

最佳答案

var frameName = "loading_000\(formattedIndex!)" 是唯一可行的选择。

func configureLoadingIcon() {
loadingImage.alpha = 0.0
loadingImage.animationImages = [UIImage]()
var frameName: String
for var i = 0; i < 48; i++ {
let formatter = NSNumberFormatter()
formatter.minimumIntegerDigits = 2
let formattedIndex = formatter.stringFromNumber(i)
var frameName = "loading_000\(formattedIndex!)"
loadingImage.animationImages?.append(UIImage(named: frameName)!)
}
loadingImage.animationDuration = 1.3
loadingImage.startAnimating()
}

关于ios - 字符串(格式 :) Crashes in iOS 7 - Need an alternative. 线程 1 : EXC_BAD_ACCESS (code=1, 地址=0x10),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30050808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com