iphone - Change ViewController Swift -


i have issue. change view controller in swift.

this part of code:

if success == "1" {     nslog("login success");      var prefs:nsuserdefaults = nsuserdefaults.standarduserdefaults()     prefs.setobject(mobile, forkey: "username")     prefs.setinteger(1, forkey: "isloggedin")     prefs.synchronize()      self.presentviewcontroller(otpvc(), animated: true, completion: nil) } 

my otpvc file is:

class otpvc: uiviewcontroller {     @iboutlet weak var smsfield: uitextfield!      @ibaction func continuebutton(sender: anyobject) {     }        } 

the problem when login successful page change , goes black!

how can fix that? in advance.

the page in blank indicator of view has not being loaded. , seems that's case:

please take closer look, creating instance of class, not instantiating view of it.

in swift can have single classes affecting several views in storyboards.

the correct way, should be:

if success == "1" {  nslog("login success");   var prefs:nsuserdefaults = nsuserdefaults.standarduserdefaults()  prefs.setobject(mobile, forkey: "username")  prefs.setinteger(1, forkey: "isloggedin")  prefs.synchronize()   var storyboard = uistoryboard(name: "main", bundle: nil) 

"main" here should name of storyboard in otpvc view is.

 var controller = storyboard.instantiateviewcontrollerwithidentifier("otpvc") as! otpvc 

"otpvc" here should storyboard identifier of view

 self.presentviewcontroller(controller, animated: true, completion: nil)  } 

update:

another root cause may identifier not set @ storyboard.

at identity inspector settings should similar to:

enter image description here

here in module, have no such class on targets says none.

this may want have at. maybe in storyboard referencing other target 1 such optvc class implementation.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -