How should I solve this error: Thread 1: EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=650 MB, unused=0x0)?

末鹿安然 提交于 2021-01-28 00:40:34

问题


I am trying to run my app which uses this GitHub project: https://github.com/PaoloCuscela/Cards/wiki/Overview

But when I run my app on my iPhone 6, it crashes and gives me the error in the title.

I've written 28 of these in my viewDidLoad function and the app runs fine on the simulator.

 let tennisCard = CardHighlight(frame: CGRect(x: 67, y: 3362, width: 250, height: 300))
           tennisCard.title = "Exercise 11"
           tennisCard.itemTitle = "Tennis"
           tennisCard.backgroundColor = UIColor(red: 0/255, green: 255/255, blue: 79/255, alpha: 1)
           tennisCard.buttonText = "See"
           tennisCard.itemSubtitle = ""
           tennisCard.tintColor = UIColor.black
           tennisCard.textColor = UIColor.black
           tennisCard.icon = UIImage(named: "Tennis")
           let tennisVC = storyboard?.instantiateViewController(withIdentifier: "TennisCardContent")
                tennisCard.shouldPresent(tennisVC, from: self)
                scrollView.addSubview(tennisCard)

回答1:


It seems like your app uses to much resources.

First of all, check if your assets have big file sizes, and if that is the case resize them to a lower resolution.

Also loading all of these (mostly hidden below the visible area) views into the scroll view at once is very memory inefficient. Try using a table view or collection view that only loads these views when visible. This could also help you get rid of code duplication



来源:https://stackoverflow.com/questions/57606436/how-should-i-solve-this-error-thread-1-exc-resource-resource-type-memory-limi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!