将UITextField添加到代码作为插座时,信号Sigabrt

时间:2015-09-01 02:26:20

标签: ios xcode swift swift2 xcode7

只要我通过" Control Drag"将我的2个文本字段连接到我的代码我无法进入视图,因为它只是退出给我

  

主题1:SIGNAL Sigabrt

应用程序运行但是只要我打开页面,这些文本框就是我的应用程序失败的地方。我在另一个应用程序上使用完全相同的代码完全相同的设置,但我没有得到我的代码在下面的错误:

DevDebug

我还会添加错误代码:

import UIKit
import MessageUI

class ContactPage: UIViewController, MFMailComposeViewControllerDelegate {

    override func prefersStatusBarHidden() -> Bool {
        return true;
    }

    var alert = UIAlertView()

    @IBOutlet var Name: UITextField!
    @IBOutlet var Message: UITextField!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func MakeCall(sender: AnyObject) {
        self.alert.title = "Calling Now..."
        self.alert.message = "You call will comence soon."
        self.alert.addButtonWithTitle("Ok")
        self.alert.show()
        let url:NSURL = NSURL(string: "tel://0394172817")!
        UIApplication.sharedApplication().openURL(url)
    }

    @IBAction func email(sender: AnyObject) {

        if (MFMailComposeViewController.canSendMail()) {

            let SubjectText = ""
            let MessageBody = ""
            let toRecipients = ["test@test.com"]

            let mc: MFMailComposeViewController = MFMailComposeViewController()
            mc.mailComposeDelegate = self
            mc.setSubject(SubjectText)
            mc.setMessageBody(MessageBody, isHTML: false)
            mc.setToRecipients(toRecipients)

            self.presentViewController(mc, animated: true, completion: nil)

        } else {
            print("No email account found")
        }
    }

    @IBAction func Submit(sender: AnyObject) {

        if (MFMailComposeViewController.canSendMail()) {

            let SubjectText = Name
            let MessageBody = Message
            let toRecipients = ["test@test.com"]

            let mc: MFMailComposeViewController = MFMailComposeViewController()
            mc.mailComposeDelegate = self
            mc.setSubject(SubjectText.text!)
            mc.setMessageBody(MessageBody.text!, isHTML: false)
            mc.setToRecipients(toRecipients)

            self.alert.title = "Registration Form"
            self.alert.message = "On this screen please press send."
            self.alert.addButtonWithTitle("Ok")
            self.alert.show()

            self.presentViewController(mc, animated: true, completion: nil)

        } else {
            print("No email account found")
        }
    }

    func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {

        switch result.rawValue {

            case MFMailComposeResultCancelled.rawValue:
                print("Mail Cancelled")
            case MFMailComposeResultSaved.rawValue:
                print("Mail Saved")
            case MFMailComposeResultSent.rawValue:
                print("Mail Sent")
                self.alert.title = "Contact Form"
                self.alert.message = "Your form has been sent."
                self.alert.addButtonWithTitle("Ok")
                self.alert.show()
            case MFMailComposeResultFailed.rawValue:
                print("Mail Failed")
                self.alert.title = "Contact Form"
                self.alert.message = "Your form failed to be sent. Please check your internet connection and try again"
                self.alert.addButtonWithTitle("Ok")
                self.alert.show()
            default:
                break
        }

        self.dismissViewControllerAnimated(false, completion: nil)

        self.performSegueWithIdentifier("ShowHome", sender: self)
    }
}

如果可能的话尽可能详细解释,我对swift和Xcode都很陌生,对一切运行方式有点不确定。提前谢谢。

1 个答案:

答案 0 :(得分:0)

如果您在查看ContactPage文件时查看Utilities Navigator,是否正确选择了目标成员资格?

Screenshot of Xcode Utilities Navigator

如果未选择目标成员资格,则编译后的二进制文件不会包含ContactPage。

如果正确选择了目标成员资格,请在Interface Builder中仔细检查该模块是否指向您的应用,而不是"无"在你的班级名称下面。

Interface Builder Utilities Navigator

最后,使用cmd + k清理项目。这也可以解决一些破坏的依赖关系。