我在.xcassets文件夹中有一组图像。 使用iOS 11和Xcode 9我用
访问它们 func searchCodes() -> NSArray {
let file = Bundle.main.url(forResource: "PickerStations", withExtension: "plist")
return NSArray(contentsOf: file!)!
}
lineCode = searchCodes().object(at: 1) as? NSDictionary
//lineFirstInitial is either C,H,J,N,P,D,M,V,B or W
let lineNameFromInitial = lineCode?.allKeys(for: lineFirstInitial).first as! String
//lineNameFromInitial is 100% correct value and loaded from an array of Strings.
//Looped through and each value added to the code below.
if let lineLabelImage = UIImage(named: lineNameFromInitial) {
lineLabelImageView.image = lineLabelImage
}
一些图像进入区块,而其他图像则没有,因为它们返回零。但是.xcassets中的图像是100%,文件名是100%正确。我尝试过对图像名称进行硬编码而不是传递变量lineNameFromInitial
,但是尽管实际存在,图像对于某些图像仍然是零。
有什么建议吗?