Custom view outlets in iOS swift are not working in view controller -


hi have taken view controller , 1 custom view in swift

viewcontroller

import uikit class viewcontroller: uiviewcontroller { var genderview : genderoptionview!  override func viewdidload() {     super.viewdidload()  loadgendercustomview() }  func loadgendercustomview() { genderview = genderoptionview(frame: cgrectmake(0,0,rectis.size.width * 0.95, rectis.size.height * 0.355)) { (screeentype) -> () in         if(screeentype == 0)         {             print("show gender");             //self.showloginscreen()         }     };      self.view.addsubview(genderview) } } 

custom view

import uikit class genderoptionview: baseview {  //static let sharedgenderoptionviewinstance = genderoptionview()  @iboutlet weak var maleimgview: uiimageview! @iboutlet weak var malebtn: uibutton! @iboutlet weak var malelbl: uilabel! internal init(frame: cgrect, onactions:(screeentype:nsinteger) -> ()){      super.init(frame: frame)      let myview  = nsbundle.mainbundle().loadnibnamed("genderoptionview", owner: self, options: nil)[0] as! uiview      self.frame = cgrectmake(frame.origin.x + 6,315,self.bounds.width,myview.bounds.height)      myview.frame = frame     //myview.backgroundcolor = uicolor.greencolor()     //self.backgroundcolor = uicolor.yellowcolor()      onactionsref = onactions;     self.addsubview(myview)      self.malebtn.alpha = 0.0// getting here.. bad excess , in console fatal error: unexpectedly found nil while unwrapping optional value } } 

i getting error in last line.. bad excess , in console fatal error: unexpectedly found nil while unwrapping optional value after loading view in view controller

and base view is

import uikit class baseview: uiview {  var onactionsref : (screeentype:nsinteger) -> () = {_ in }; } 

use

myview.malebtn.alpha = 0.0 

as not loading nib in self , loading in myview


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -