ios - ScrollView unable to display image which passed from another VC -


i need display image pass in viewcontroller

first,i have tested using imageview display image , works below:

thanks. appreciated.

 class viewcontroller: uiviewcontroller, uiscrollviewdelegate {      @iboutlet weak var tempimgview: uiimgeview!     var passinimg: uiimage?      override func viewdidload() {          super.viewdidload()         tempimgview.image = passinimg!     }  

when use uiscrollview ( scrolling large passinimg) , below code not working

probelm:

error : fatal error: unexpectedly found nil while unwrapping optional value

but have tested pass in image in above code.

what need done scrollview?

  1. should used in viewdidload?
  class viewcontroller: uiviewcontroller, uiscrollviewdelegate {       @iboutlet weak var myuiscrollview: uiscrollview!      var myimgview: uiimageview!     var passinimg: uiimage?       override func viewdidload() {         super.viewdidload()           self.myuiscrollview.maximumzoomscale = 10.0          self.myuiscrollview.minimumzoomscale = 1.0          self.myuiscrollview.delegate = self          myimgview.image = passinimg!          self.myuiscrollview.addsubview(myimgview)      }       func viewforzoominginscrollview(scrollview: uiscrollview) -> uiview? {          return myimgview     }  

first check if myuiscrollview connected outlet in storyboard , check before using optional variable:

if let img = passinimg {     myimgview.image =  img } 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -