gpt4 book ai didi

ios - 将 UITextField 添加到代码作为 socket 时发出 Sigabrt 信号

转载 作者:行者123 更新时间:2023-11-30 14:06:31 24 4
gpt4 key购买 nike

一旦我通过“控制拖动”将 2 个文本字段连接到我的代码,我就无法进入 View ,因为它只是退出来给我

Thread 1: SIGNAL Sigabrt

应用程序运行,但一旦我打开这些文本框所在的页面,我的应用程序就会失败。我在另一个应用程序上使用完全相同的代码进行了完全相同的设置,但没有收到错误,我的代码如下:

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)
}
}

我还将添加错误代码:

2015-09-01 12:02:43.976 App Name[91111:2205337] Unknown class ContactPage in Interface Builder file. 
2015-09-01 12:02:44.078 App Name[91111:2205337] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7ff781d0a110> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Message.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001051a99b5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001071ffdeb objc_exception_throw + 48
2 CoreFoundation 0x00000001051a95f9 -[NSException raise] + 9
3 Foundation 0x0000000105573fdb -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x0000000105f9c418 -[UIViewController setValue:forKey:] + 88
5 UIKit 0x00000001061af2c7 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x00000001050ea590 -[NSArray makeObjectsPerformSelector:] + 224
7 UIKit 0x00000001061adcaa -[UINib instantiateWithOwner:options:] + 1864
8 UIKit 0x0000000105fa2df4 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9 UIKit 0x0000000105fa3720 -[UIViewController loadView] + 178
10 UIKit 0x0000000105fa3a22 -[UIViewController loadViewIfRequired] + 138
11 UIKit 0x0000000105fa4054 -[UIViewController view] + 27
12 UIKit 0x00000001066d36d2 -[_UIFullscreenPresentationController _setPresentedViewController:] + 87
13 UIKit 0x0000000105f74a4e -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133
14 UIKit 0x0000000105fb65ca -[UIViewController _presentViewController:withAnimationController:completion:] + 3736
15 UIKit 0x0000000105fb94b3 -[UIViewController presentViewController:animated:completion:] + 343
16 UIKit 0x00000001064eee8b __67-[UIStoryboardModalSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 243
17 UIKit 0x00000001064dd523 -[UIStoryboardSegueTemplate _perform:] + 449
18 UIKit 0x00000001064dd5ea -[UIStoryboardSegueTemplate perform:] + 156
19 UIKit 0x0000000105e1f522 -[UIApplication sendAction:to:from:forEvent:] + 92
20 UIKit 0x0000000105f7ec06 -[UIControl sendAction:to:forEvent:] + 67
21 UIKit 0x0000000105f7eeac -[UIControl _sendActionsForEvents:withEvent:] + 273
22 UIKit 0x0000000105f7e008 -[UIControl touchesEnded:withEvent:] + 601
23 UIKit 0x0000000105e8715f -[UIWindow _sendTouchesForEvent:] + 835
24 UIKit 0x0000000105e87d4d -[UIWindow sendEvent:] + 865
25 UIKit 0x0000000105e3c2ae -[UIApplication sendEvent:] + 263
26 UIKit 0x0000000105e1836c _UIApplicationHandleEventQueue + 6693
27 CoreFoundation 0x00000001050d5b21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
28 CoreFoundation 0x00000001050cba4c __CFRunLoopDoSources0 + 556
29 CoreFoundation 0x00000001050caf03 __CFRunLoopRun + 867
30 CoreFoundation 0x00000001050ca918 CFRunLoopRunSpecific + 488
31 GraphicsServices 0x000000010acdcad2 GSEventRunModal + 161
32 UIKit 0x0000000105e1d99e UIApplicationMain + 171
33 App Name 0x0000000104fa749d main + 109
34 libdyld.dylib 0x0000000107d6492d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

如果可能的话尽可能详细地解释一下,我对 swift 和 Xcode 很陌生,并且有点不确定一切是如何运行的。提前致谢。

最佳答案

如果您在查看 ContactPage 文件时查看实用程序导航器,则目标成员资格选择是否正确?

Screenshot of Xcode Utilities Navigator

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

如果目标成员资格选择正确,请在 Interface Builder 中仔细检查模块是否指向您的应用程序,而不是类名下方的“None”。

Interface Builder Utilities Navigator

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

关于ios - 将 UITextField 添加到代码作为 socket 时发出 Sigabrt 信号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32322609/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com