![](/img/trans.png)
[英]How do I add an IBOutlet to subclass in another file?
我瀏覽了 Apple 的書“在 Swift 數據集合中開發”,起點如下: 我們有一個帶有“Label Outlet”的表格視圖 controller 我們有一個名為“EmojiTableViewController”的第一個 Swift 文件,主文件為 class。這個 class 連接到 Vie ...
[英]How do I add an IBOutlet to subclass in another file?
我瀏覽了 Apple 的書“在 Swift 數據集合中開發”,起點如下: 我們有一個帶有“Label Outlet”的表格視圖 controller 我們有一個名為“EmojiTableViewController”的第一個 Swift 文件,主文件為 class。這個 class 連接到 Vie ...
[英]How to access variables inside the XIB
我創建了一個名為UserInfoView的可重用自定義視圖和一個 XIB 文件,我想將其嵌入故事板中。 我將根視圖的類以及自定義視圖的文件所有者設置為 XIB 文件中的UserInfoView 。 我在 XIB 文件和 Swift 文件中創建了標簽,並通過文件所有者鏈接它們。final class ...
[英]How to access an Interface Builder UILabel with code?
Interface Builder 中有一個沒有自定義類或標記的 UILabel。 我需要以編程方式更改此 UILabel 的 y 坐標。 我知道我可以通過設置標簽和使用 viewWithTag 來引用 UILabel。 但是我該如何使用 IBOutlet 呢? 我可以在 IB 中設置自定義類,然 ...
[英]Set UIBarButtonItem's background color working with Storyboard swift
我知道這確實經常被問到,但我找不到任何關於使用IBOutlet執行此操作的信息。 我已經找到了一些代碼,如何在使用代碼創建UIBarButtonItem時設置它的背景顏色。 但是我已經從我在Storyboard中創建的 UIBarButtonItem 實現了許多連接。 是否可以設置Storybo ...
[英]Swift macOS : view is not loaded and IBOulets are nil in View Controller
我正在寫一個簡單的增值稅計算器 我想改變 TextFields 的外觀,將一個聚焦為白色背景,其他聚焦為灰色背景。 Textfields 的事件發送似乎是在離開焦點時,所以我想在進入焦點時更改顏色,我在 FATextfield 中創建了 NSTextField 的子類。 檢測哪個文本域作為焦點是 ...
[英]Swift error "Only instance properties can be declared @IBOutlet"
我正在嘗試制作帶有圓角的按鈕。 到目前為止,這就是我所擁有的。 我不斷收到“只能聲明實例屬性@IBOutlet”錯誤。 ...
[英]How to assign value to an outlet after delegating it?
所以我的應用程序有 3 個屏幕:Main、Second 和 Result(非常簡單) 在主屏幕上,我顯示一個 label 和按鈕來改變它在第二個中,我使用 textinput 更改 label 並將其傳遞給 Result(有導航控制器) 在最后一個屏幕上,我顯示結果和 2 個按鈕:保存和取消我的問 ...
[英]Unrecognized Selector sent to Instance in UI Textfield even after checking IB Outlets
所以我正在 Xcode 中創建一個社交媒體應用程序,並嘗試創建注冊按鈕頁面。 但是,我注意到每次我點擊用戶名、密碼或任何其他文本字段時,而不是彈出 ios 鍵盤時,我都會收到此錯誤: 無法識別的選擇器發送到實例我查了如何解決這個問題,上面說要檢查你的網點。 但是,我已經檢查了我的網點一百萬次,並且知 ...
[英]Access a IBOutlet id defined in one class in another
您好,我有一個 IBOutlet id,用於在類中定義的視圖,我需要從另一個類訪問它,我該怎么做? 我還在學習 ObjC,所以我很感激你對我的耐心,因為我正在努力學習盡可能多的東西! 添加更多上下文:我有一個控制器,它是我的視圖 IBOutlet 被定義的地方,然后我有一個類來做一些繪圖 - 我 ...
[英]All IBOutlets in a view controller are nil
在我的視圖 Controller 中,所有 IBOutlets 都為零。 我不知道為什么會這樣我收到以下錯誤: 線程 1:致命錯誤:在隱式展開可選值時意外發現 nil 我已使用此代碼從另一個 controller 設置變量 finalScore: 我在這一行遇到錯誤:這是圖像它甚至顯示這里的網點為零 ...
[英]iOS: Inheritance with different xib files
UIViewA 在 .xib 和 .swift 中定義。 我想用它自己的 .xib 創建一個 UIView,它繼承自 UIViewA 並帶有幾個額外的屬性。 所以: UIViewA 和 UIViewB 都有titleLabel 和subtitleLabel。 它們只是在xibs中的位置不同 ...
[英]How can I pass a textfield value from one ViewController to a second ViewController (MacOS Swift)?
我正在處理一個項目,我的 ViewController 文件開始變得很長。 因此,我想在第二個 ViewController 中定義我的所有函數,以便我可以從我的第一個 ViewController 中刪除一些代碼。 這是有效的,除了當我嘗試從我的 FirstViewController 中定義的 ...
[英]UILabel inside UICollectionViewCell is nil
設置值時,UICollectionViewCell 內的 Label 為 nil。 因此,使用 storyboard 中的自定義單元格,不在 viewDidLoad 中注冊。 下面是我的代碼: 更新: ...
[英]I just instantiated the ViewController, why is its IBOutlet nil?
如果我需要在這里使用它怎么辦? vc.lable 為零 ViewController 中有一個 IBOutlet ...
[英]How can an outlet be nil even though it has been set
我通過containers有一個帶有兩個embedded viewController的viewControllers 。 然后,我創建了從父viewController's containers到父class的outlets 。 我想根據某些條件隱藏或顯示containers 。 但如果我簡單地寫 ...
[英]Crashes when use Storyboards and XIBs over Swift package manager
我們在 Swift 中有一個 UI 庫,其中包含我們公司 iOS 應用程序的 UI 元素(有一些 xib、一些故事板和一些 swift 代碼)。 我們已經決定為這個 lib 添加對 swift package 管理器的支持(在添加 Cocoapods 之前)並且每當 xib 文件和 swift 代碼 ...
[英]How can I access an UIButton in the ViewController Class from a function parameter
我如何從帶有 2 個參數的函數訪問 IBOutlet UIButton ...
[英]View Controller loses connection to constraints in IBOutlets when switching tabs in UITabView
好的,這是我的代碼的相關部分: class MyViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var questionView: QuestionVi ...
[英]Iboutlets have nil value on present call
@objc func handleGoToSearch() { // present(UINavigationController(rootViewController: searchDisplayController()), animated: true, completion: n ...
[英]Is it possible to add a datePicker into a reusable cell?
以應用照片為例所以我一直在嘗試通過上面照片中的文本字段添加一個 datePicker。 我知道如何創建 datePicker 本身,但我就是不知道如何連接它。 我為文本字段創建了 cocoa touch class 文件,但無法將 storyboard 中的文本字段連接到該文件。 我也嘗試在身份檢 ...