iOS-拉outlet到代碼區錯誤:Could not insert new outlet connection: Could not find any...

拉outlet到代碼區提示錯誤:

Could not insert new outlet connection: Could not find any information for the class named XXX

錯誤緣由:

Xcode抽風swift

解決方法(選其中一個,第一個不行用第二個,以此類推):

  • Xcode > Product > Clean Build Folder bash

    屏幕快照 2019-04-29 下午4.30.54.png

  • 徹底重啓Xcode(必須在程序塢右擊選退出) app

    屏幕快照 2019-04-29 下午4.32.47.png

  • 在代碼區手動寫 @IBOutlet weak ...@IBAction func ...,而後點代碼左邊圓圈反拖給storyboard上的控件ide

    @IBOutlet weak var viewName: UIView!
    // or
    @IBAction func viewTapped(_ sender: Any) { }
    複製代碼
  • 刪除Derived Data文件夾 : Xcode > Preferences > Locations ,點Derived Data下面的箭頭到達文件夾,刪除裏面以這個項目爲前綴的文件夾 ui

    屏幕快照 2019-04-29 下午4.38.59.png

  • 右擊出錯的這個class的swift文件,並刪掉引用-Remove reference (注意不是 Move to Trash),而後在目錄處右擊選擇Add Files to xxx,把剛剛刪掉引用的那個文件加進來: spa

    屏幕快照 2019-04-29 下午4.44.24.png

廣告時間:小弟的iOS12零基礎視頻教程,進階版也正在製做中:

m.study.163.com/provider/48…code

相關文章
相關標籤/搜索