只要我通过" 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都很陌生,对一切运行方式有点不确定。提前谢谢。