2015-10-14 61 views
0

展开一个可选值(LLDB)我有一个LoginViewController与viewDidLayoutSubviews()的功能和作用我有这样的代码来创建文本框底部只有边框内,致命错误:意外发现零,而在的UITextField

let txt_border = CALayer() 
     let txt_pass_border = CALayer() 
     let border_width = CGFloat(2.0) 
     txt_border.borderColor = UIColor.grayColor().CGColor 
     txt_pass_border.borderColor = UIColor.grayColor().CGColor 
     txt_border.frame = CGRect(x: 0, y: txt_login_Email.frame.size.height - border_width, width: txt_login_Email.frame.size.width, height: txt_login_Email.frame.size.height) 
     txt_pass_border.frame = CGRect(x: 0, y: txt_login_Password.frame.size.height - border_width, width: txt_login_Password.frame.size.width, height: txt_login_Password.frame.size.height) 
     txt_border.borderWidth = border_width 
     txt_pass_border.borderWidth = border_width 
     txt_login_Email.layer.addSublayer(txt_border) 
     txt_login_Email.layer.masksToBounds = true 

     txt_login_Password.layer.addSublayer(txt_pass_border) 
     txt_login_Password.layer.masksToBounds = true 

但在运行程序的时候,显示错误 output Console

,并强调代码 enter image description here

什么需要做的改变这个错误?

+0

很有可能txt_login_Emai是无 –

+0

对不起,我不明白你 –

+1

你知道什么是零吗? –

回答

1

如果你重载一个函数,你将不得不始终调用它的超级函数。在这种情况下,这应该是您的第一线,而不是打印(“边界”)

super.viewDidLayoutSubviews() 

一旦做到这一点,检查是否

txt_login_Email 

不为零。

+0

正如你们提到的我检查txt_login_Email是零或不,它显示零。所以我需要改变什么? – Joker

0

所以在SO搜索解决方案中徘徊我从here 得到了我的问题的答案。 Rob回答。我已经添加

let loginViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("loginVC") as! LoginViewController 

Appdelegate.swift文件

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
let loginViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("loginVC") as! LoginViewController 
    } 

,那就是面对就去了问题里面。

从我开始使用教程中的MMDrawerController时,问题就开始了。作为iOS的初学者,他只是遵循他的指示,并发现自己处于一个坑中。只是为我的愚蠢埋怨自己。现在我需要再次做抽屉的东西。希望有一天能帮助别人。

相关问题