swift - app crash on iphone not on simulator -


whenever tap on last row in column, app crashes on iphone, not on simulator. else works fine. not error message. code working fine along simulator.

import uikit  class earthvc: uiviewcontroller {      @iboutlet var slideshow1: uiimageview!      override func viewdidload() {         super.viewdidload()          // additional setup after loading view.          slideshow1.animationimages = [              uiimage(named: "earth1.jpg")!,             uiimage(named: "earth2.jpg")!,             uiimage(named: "earth3.jpg")!,             uiimage(named: "earth4.jpg")!,             uiimage(named: "earth5.jpg")!,             uiimage(named: "earth6.jpg")!,             uiimage(named: "earth7.jpg")!,             uiimage(named: "earth8.jpg")!,             uiimage(named: "earth9.jpg")!,             uiimage(named: "earth10.jpg")!,             uiimage(named: "earth11.jpg")!,             uiimage(named: "earth12.jpg")!,             uiimage(named: "earth13.jpg")!,             uiimage(named: "earth14.jpg")!,             uiimage(named: "earth15.jpg")!,             uiimage(named: "earth16.jpg")!,             uiimage(named: "earth17.jpg")!,             uiimage(named: "earth18.jpg")!,             uiimage(named: "earth19.jpg")!,             uiimage(named: "earth20.jpg")!,             uiimage(named: "earth21.jpg")!,             uiimage(named: "earth22.jpg")!,             uiimage(named: "earth23.jpg")!,             uiimage(named: "earth24.jpg")!,             uiimage(named: "earth25.jpg")!,             uiimage(named: "earth26.jpg")!,             uiimage(named: "earth27.jpg")!,             uiimage(named: "earth28.jpg")!,             uiimage(named: "earth29.jpg")!,             uiimage(named: "earth30.jpg")!,             uiimage(named: "earth31.jpg")!         ]          slideshow1.animationduration = 93         slideshow1.startanimating()     }      override func didreceivememorywarning() {         super.didreceivememorywarning()         // dispose of resources can recreated.     }       /*     // mark: - navigation      // in storyboard-based application, want little preparation before navigation     override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {         // new view controller using segue.destinationviewcontroller.         // pass selected object new view controller.     }     */  } 

with of images loading, it's running out of memory on phone - had problem recently. no error, did see "low memory warning" on debug console.

to diagnose it, make array of image names, loop on populate array of uiimage's, check load go. can set animationimages. so,

let imagenames = [     "earth1.jpg",     "earth2.jpg",     // ...     "earth31.jpg" ]  var images = [uiimage]() name in imagenames {     guard let image = uiimage(named: name) else {         nslog("failed load image \(name)")         continue     }     images.append(image) } slideshow1.animationimages = images 

you can set breakpoint @ continue see how far getting.

assuming what's going on, fix problem, need use image editing program make images smaller (in terms of pixels). in case, images photographs taken @ 4000x6000 pixels; found resizing them size displayed made difference. also, saving files 50% loss made them 15% of original size (in terms of bytes), made them load lot faster. showed original , resized/lossy images colleagues, couldn't see difference (one thought joke of kind).


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -