我试着编译我的第一个iOS Hello应用程序.
ViewController.swift
//
// ViewController.swift
// My First Project
import UIKit
class ViewController: UIViewController {
// Declare components
@IBOutlet weak var inputLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func submitBtn(_ sender: Any) {
inputLabel.text = "Hello World"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Run Code Online (Sandbox Code Playgroud)
越来越 Build Succeeded
但是大约5秒后,我得到了这个
0x0000000103915f69 -[UIApplication workspaceDidEndTransaction:] + 188
18 FrontBoardServices 0x000000010770f723 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
19 FrontBoardServices 0x000000010770f59c -[FBSSerialQueue _performNext] + 189
20 FrontBoardServices 0x000000010770f925 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
21 CoreFoundation 0x0000000105ff0311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22 CoreFoundation 0x0000000105fd559c __CFRunLoopDoSources0 + 556
23 CoreFoundation 0x0000000105fd4a86 __CFRunLoopRun + 918
24 CoreFoundation 0x0000000105fd4494 CFRunLoopRunSpecific + 420
25 UIKit 0x00000001039147e6 -[UIApplication _run] + 434
26 UIKit 0x000000010391a964 UIApplicationMain + 159
27 My First Project 0x0000000102e6db3f main + 111
28 libdyld.dylib 0x0000000106f7868d start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Run Code Online (Sandbox Code Playgroud)
我曾经有这个
我更新了这个
重新运行并仍在发生......
重新运行并仍在发生......
当您删除自己的参考插座ViewController而忘记从中删除连接时,会发生此问题storyboard。
完美的连接?
完美的参考插座如下图所示。
现在让我们从
.h文件中删除引用出口
问题??
如果我们从.h文件Xcode中删除引用出口,则会在Storyboard中发出警告。这是技巧,您可以找到从类中删除了哪个插座。
我希望这能帮到您 。
解
在您的情况下,您可能已将名称更改为lable,inputLable因此您需要执行以下操作:
断开与的连接label。将控制器重新连接到inputLabel。
小智 1
确保故事板元素已连接到代码中的插座。尝试删除连接检查器中的所有连接并重新连接元素
当您转到 main.storyboard 时,右侧有一个面板,最右边的一个是连接检查器。在那里,您必须通过按连接中的小“x”来删除所有连接。
它看起来应该像这样有点熟悉,但是 这个屏幕截图中的名称不同
全部删除
同样在 viewController.swift 文件中,删除所有 @IBOutlet 行。
然后再次将您的插座连接到 ViewController.swift 文件,就像您之前所做的那样
对于仅更改代码中的标签,它最终应该看起来像这个最终屏幕截图
注意右边的插座
我希望这能帮到您!