
该应用程序在设备上正常运行,直到最近添加了一些代码更改,这是我认为问题所在.我添加了包含可疑代码的整个vIEwDIDLoad bellow(在代码中指出).
我注意到的另一件事是调试导航器中的cpu使用率大约为130%,而应用程序在设备上发生问题时在sim中运行.
overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() // screen size for collection vIEw cell screenSize = UIScreen.mainScreen().bounds screenWIDth = screenSize.wIDth screenHeight = screenSize.height dimVIEw.Alpha = 0 openingHoursVIEw.Alpha = 0 resDescriptionLabel.layer.bordercolor = UIcolor.blackcolor().CGcolor resDescriptionLabel.layer.borderWIDth = 2 resDescriptionLabel.layer.cornerRadius = 4 //add logo to nav bar let navbarlogo: UIImageVIEw = UIImageVIEw(frame: CGRectMake(0,120,36)) navbarlogo.image = UIImage(named: "logo") self.navigationItem.TitleVIEw = navbarlogo self.resImage.image = UIImage(named: "placeholder") if let checkedUrl = NSURL(string: "http://staging.API.cheapeat.com.au/restaurants/\(self.venueID)/photo") { downloadImage(checkedUrl) } self.resname.text = " " + self.venuename + " " self.resAdd.text = " " + self.venueAdd + " " self.resPhone.text = "\(self.venuePH)" self.resPhoneNumber.text = self.venuePH self.resWebText.text = "\(self.venueWeb)" ///////////////////// new code starts here ////////////// var paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = NSTextAlignment.JustifIEd paragraphStyle.lineBreakMode = NSlineBreakMode.ByWorDWrapPing var attributedString = NSAttributedString(string: self.venueInfo,attributes: [ NSParagraphStyleAttributename: paragraphStyle,NSBaselineOffsetAttributename: NSNumber(float: 0) ]) self.resDescriptionLabel.attributedText = attributedString aboutVenueLabelWIDthConstraint.constant = screenWIDth - 16 resDescriptionLabel.edgeInsets.left = 10 resDescriptionLabel.edgeInsets.top = 10 resDescriptionLabel.edgeInsets.right = 10 resDescriptionLabel.edgeInsets.bottom = 10 resDescriptionLabel.layoutIfNeeded() backgroundImageHeightConstraint.constant = resDescriptionLabel.bounds.height + 130 // set content vIEw height i.e. scrollable area // (dynamic height of label + combined height of all other content and contraints) contentVIEwHeightConstraint.constant = resDescriptionLabel.bounds.height + 790 /////////////////// new code ends here /////////////// self.displayMap(self.venueLat,lng: self.venueLng) self.getArrayForCollection() self.getArrayValues() dispatch_async(dispatch_get_global_queue( disPATCH_QUEUE_PRIORITY_DEFAulT,0),{ () -> VoID in self.getDataForNexttable() }) mon.text = timeFormatting(openingHours,day: "Monday") tue.text = timeFormatting(openingHours,day: "Tuesday") wed.text = timeFormatting(openingHours,day: "Wednesday") thu.text = timeFormatting(openingHours,day: "Thursday") fri.text = timeFormatting(openingHours,day: "FrIDay") sat.text = timeFormatting(openingHours,day: "Saturday") sun.text = timeFormatting(openingHours,day: "Sunday")}解决方法 我找到了罪魁祸首,事实证明它毕竟不在代码中.我在scrollVIEw中设置了一些背景图像,分辨率很高(5000×5000).他们绝对是在咀嚼内存(在调试器中达到400mb左右).我调整了图像大小,问题解决了. 总结 以上是内存溢出为你收集整理的iOS应用程序在Xcode模拟器中运行良好,但速度很慢并且在设备上崩溃全部内容,希望文章能够帮你解决iOS应用程序在Xcode模拟器中运行良好,但速度很慢并且在设备上崩溃所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)