我有一个UICollectionViewController
加载了来自文档目录的图像。在模拟器(iPhone 6s plus)上我似乎没有任何问题,但在iPhone 5设备上,当图像数量增加而我必须滚动时,应用程序只会崩溃。这是我的代码:
在cellForItemAtIndexPath中:
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier,
forIndexPath: indexPath) as! MyCollectionViewCell
cell.layer.shouldRasterize = true
cell.layer.rasterizationScale = UIScreen.mainScreen().scale
if directoryUrls.count > 0
{
var image = UIImage (named: "pending.png")
let ImgPath = self.documentsPath.URLByAppendingPathComponent("\(String(NSLocalizedString("attachments_folder", comment: "")))/\(self.Attachments[indexPath.row].Name)")
var mimeType = ""
if (self.fileManager.fileExistsAtPath(ImgPath.path!))
{
mimeType = mimeTypeForPath(ImgPath.path!)
}
if (!mimeType.isEmpty)
{
if(mimeType.containsString("image"))
{
Nuke.taskWithURL(ImgPath)
{
self.MimArray.append("image")
self.ImageAttachmentsOnly[self.i] = self.Attachments[indexPath.row]
self.i++
cell.Image.image = $0.image
self.Images.append($0.image!)
}.resume()
}
}
cell.ImageLabel.text = self.Attachments[indexPath.row].Name
cell.Image.contentMode = .ScaleAspectFit
}
return cell
如果相关,则CollectionViewCell中的图像大小为70 * 70。
如果您希望我提供更多代码,我会。
这就是我从日志中得到的所有内容:
Communications error: <OS_xpc_error: <error: 0x38504654> { count = 1, contents =
"XPCErrorDescription" => <string: 0x38504854> { length = 22, contents = "Connection interrupted" }
}>
Terminating since there is no system app.