使用xib控件快速崩溃

时间:2014-12-02 13:50:55

标签: ios swift xib nib nsobject

我试图创建一些简单的弹出窗口。它只包含2个文本字段和2个按钮 - "取消" &安培; "完成&#34 ;.我已经创建了单独的.xib模板和NSObject类。

这是我创建课程并加载.xib

的方法
class AddressPopup: NSObject, UITextFieldDelegate
{
    private var originView: UIView!
    private var overlay: UIView!

    private var textFieldNumber: UITextField!
    private var textFieldStreet: UITextField!

    private var buttonDone:   UIButton!
    private var buttonCancel: UIButton!

    var rootView: UIView!
    var data = [String:String]()

    init(inView rootView: UIView, withData data: [String:String])
    {
        super.init()

        // Set basic data
        self.rootView = rootView
        self.data = data

        // Attach view
        self.originView = NSBundle.mainBundle().loadNibNamed("AddressPopup2", owner: self, options: nil)[0] as? UIView
        self.originView.layer.cornerRadius = 5

        textFieldNumber = originView.viewWithTag(200) as UITextField
        textFieldStreet = originView.viewWithTag(201) as UITextField

        textFieldNumber.delegate = self
        textFieldStreet.delegate = self

        // Buttons
        buttonDone   = originView.viewWithTag(301) as UIButton
        buttonCancel = originView.viewWithTag(300) as UIButton

        buttonDone.addTarget(self, action: "buttonDoneAction", forControlEvents: .TouchUpInside)
    }
    // Other methods

每当我尝试将其中一个文本字段作为第一响应者或点击done按钮应用程序崩溃而没有任何描述时。只需打印(lldb)即可。如果我删除行,将委托设置为textfields - 一切正常。或者,如果我删除addTarget应用的行,则不会崩溃。

我知道我的文字字段不是零,因为我可以设置一些文字。我无法弄清楚导致坠机的原因。

0 个答案:

没有答案